| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /*
- * @Author: deng.yinping deng.yinping@muchinfo.cn
- * @Date: 2024-02-22 11:11:03
- * @LastEditors: deng.yinping deng.yinping@muchinfo.cn
- * @LastEditTime: 2024-04-17 14:52:08
- * @FilePath: \MTP20_IF\controllers\user\login.go
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
- package user
- import (
- "fmt"
- "mtp2_if/global/app"
- "mtp2_if/global/e"
- "mtp2_if/logger"
- "mtp2_if/models"
- "net/http"
- "github.com/gin-gonic/gin"
- )
- // GetLoginIDReq 获取登录ID请求参数
- type GetLoginIDReq struct {
- UserName string `form:"username" binding:"required"`
- }
- // GetLoginID 获取登录ID
- // @Summary 获取登录ID
- // @Description UserName 可传入“登录账号”、“登录代码”和“手机号码”
- // @Produce json
- // @Param username query string true "登录代码"
- // @Success 200 {object} app.Response
- // @Failure 500 {object} app.Response
- // @Router /User/GetLoginID [get]
- // @Tags 用户信息
- func GetLoginID(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req GetLoginIDReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("GetLoginID failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- // 通过登录代码查询登录账号
- if loginaccount, _ := models.GetLoginAccountByLoginCode(req.UserName); loginaccount != nil {
- appG.Response(http.StatusOK, e.SUCCESS, fmt.Sprintf("%v", loginaccount.Loginid))
- return
- }
- // // 通过LoginAccount表手机号码查询登录账号
- // if loginaccount, _ := models.GetLoginAccount2(req.UserName); loginaccount != nil {
- // appG.Response(http.StatusOK, e.SUCCESS, fmt.Sprintf("%v", loginaccount.Loginid))
- // return
- // }
- // // 通过UserInfo表手机号码查询登录账号
- // if loginaccount, _ := models.GetLoginAccountByMobile(req.UserName); loginaccount != nil {
- // appG.Response(http.StatusOK, e.SUCCESS, fmt.Sprintf("%v", loginaccount.Loginid))
- // return
- // }
- // 根据登录账号与手机号绑定表获取登录账号(上面两个查询不正确 20240417)
- // GetLoginAccountByMobile2 通过手机号码查询登录账号信息(三方认证表 userauthinfo)
- if loginaccount, _ := models.GetLoginAccountByMobile2(req.UserName); loginaccount != nil {
- appG.Response(http.StatusOK, e.SUCCESS, fmt.Sprintf("%v", loginaccount.Loginid))
- return
- }
- // 找不到或查询错误,都把请求代码返回去
- appG.Response(http.StatusOK, e.SUCCESS, req.UserName)
- }
|