getuserinfo

This commit is contained in:
苏尹岚
2020-11-20 10:56:24 +08:00
parent bccf4b8d4f
commit f63794c9e1
2 changed files with 51 additions and 0 deletions

View File

@@ -286,6 +286,48 @@ func (c *User2Controller) UpdateUserByMiniInfo() {
})
}
type UserInfoWithWeixin struct {
*weixinapi.MiniUserInfo
IsExist bool `json:"isExist"`
}
// @Title 根据小程序jsCode查询用户信息
// @Description 根据小程序jsCode查询用户信息
// @Param token header string true "认证token"
// @Param data query string true "加密数据"
// @Param iv query string true "iv"
// @Param jsCode query string false "小程序jsCode"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetUserByMiniInfo [get]
func (c *User2Controller) GetUserByMiniInfo() {
c.callGetUserByMiniInfo(func(params *tUser2GetUserByMiniInfoParams) (retVal interface{}, errCode string, err error) {
authInfo, err := params.Ctx.GetV2AuthInfo()
if err == nil {
decryptedDataBase64, err2 := weixin.AutherObjMini.DecryptData(authInfo, GetComposedCode(&c.Controller, params.JsCode), params.Data, params.Iv)
if err = err2; err == nil {
var userInfo *weixinapi.MiniUserInfo
if err = utils.UnmarshalUseNumber([]byte(decryptedDataBase64), &userInfo); err == nil {
var result *UserInfoWithWeixin
if err = utils.UnmarshalUseNumber(utils.MustMarshal(userInfo), &result); err == nil {
if userInfo.PhoneNumber != "" {
if user, err := dao.GetUserByID(dao.GetDB(), "mobile", userInfo.PhoneNumber); err == nil {
if user != nil {
result.IsExist = true
} else {
result.IsExist = false
}
retVal = result
}
}
}
}
}
}
return retVal, "", err
})
}
// @Title 会员充值
// @Description 会员充值
// @Param token header string true "认证token"

View File

@@ -583,6 +583,15 @@ func init() {
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
beego.ControllerComments{
Method: "GetUserByMiniInfo",
Router: `/GetUserByMiniInfo`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"],
beego.ControllerComments{
Method: "GetUserCityManager",