| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package zhongrong
- import (
- "mtp2_if/global/app"
- "mtp2_if/global/e"
- "mtp2_if/logger"
- "mtp2_if/models"
- "net/http"
- "github.com/gin-gonic/gin"
- )
- type GetUserInfoReq struct {
- Param string `form:"param" binding:"required"` // 登录账号、手机号精确查询用户
- }
- type GetUserInfoRsp struct {
- UserId int64 `json:"userid"` // 用户ID
- Customername string `json:"customername"` // 客户名称
- }
- // GetUserInfo 登录账号、手机号精确查询用户
- // @Summary 登录账号、手机号精确查询用户
- // @Produce json
- // @accept application/json
- // @Param param query int true "登录账号或手机号"
- // @Success 200 {array} GetUserInfoRsp
- // @Failure 500 {object} app.Response
- // @Router /Zhongrong/GetUserInfo [get]
- // @Tags 中融
- func GetUserInfo(c *gin.Context) {
- appG := app.Gin{C: c}
- // 获取请求参数
- var req GetUserInfoReq
- if err := appG.C.ShouldBindQuery(&req); err != nil {
- logger.GetLogger().Errorf("GetUserInfo failed: %s", err.Error())
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- if userinfo, err := models.GetUserInfoByUserIDorMobile(req.Param); err == nil {
- rsp := make([]GetUserInfoRsp, 0)
- if userinfo != nil {
- rsp = append(rsp, GetUserInfoRsp{
- UserId: userinfo.Userid,
- Customername: userinfo.Customername,
- })
- }
- appG.Response(http.StatusOK, e.SUCCESS, rsp)
- } else {
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- }
- }
|