- BindMiniProgram

This commit is contained in:
gazebo
2019-01-28 12:26:26 +08:00
parent eaee327de2
commit bc1ac33874
4 changed files with 91 additions and 57 deletions

View File

@@ -122,7 +122,7 @@ func (c *AuthController) SendMobileVerifyCode() {
}
// @Title 绑定手机
// @Description 绑定手机
// @Description 绑定手机,待删除
// @Param token header string true "认证token"
// @Param mobile formData string true "手机号"
// @Param code formData string true "验证码"
@@ -140,39 +140,6 @@ func (c *AuthController) BindMobile() {
})
}
// @Title 绑定手机
// @Description 绑定手机(调用此方法前先需要以短信方式登录)
// @Param token header string true "认证token"
// @Param code formData string true "小程序用户code"
// @Param nickname formData string false "用户名"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /MiniBindWeiXin [post]
func (c *AuthController) MiniBindWeiXin() {
c.callMiniBindWeiXin(func(params *tAuthMiniBindWeiXinParams) (retVal interface{}, errCode string, err error) {
err = weixin.AutherMini.BindWeiXin(params.Ctx, params.Code, params.Nickname)
if err == auth.ErrUserNotExist {
return retVal, model.ErrCodeUserNotExist, err
}
return retVal, "", err
})
}
// @Title 解密小程序数据
// @Description 解密小程序数据
// @Param token header string true "认证token"
// @Param data formData string true "加密数据"
// @Param iv formData string true "iv"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /MiniDecryptData [post]
func (c *AuthController) MiniDecryptData() {
c.callMiniDecryptData(func(params *tAuthMiniDecryptDataParams) (retVal interface{}, errCode string, err error) {
retVal, err = weixin.AutherMini.DecryptData(params.Ctx, params.Data, params.Iv)
return retVal, "", err
})
}
// @Title 微信公众号绑定手机2
// @Description 微信公众号绑定手机2
// @Param openID formData string true "微信公众号ID"
@@ -192,3 +159,53 @@ func (c *AuthController) BindMobile2() {
return retVal, "", err
})
}
// @Title 绑定手机
// @Description 绑定手机(调用此方法前先需要以短信方式登录),待删除
// @Param token header string true "认证token"
// @Param code formData string true "小程序用户code"
// @Param nickname formData string false "用户名"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /MiniBindWeiXin [post]
func (c *AuthController) MiniBindWeiXin() {
c.callMiniBindWeiXin(func(params *tAuthMiniBindWeiXinParams) (retVal interface{}, errCode string, err error) {
err = weixin.AutherMini.BindWeiXin(params.Ctx, params.Code, params.Nickname)
if err == auth.ErrUserNotExist {
return retVal, model.ErrCodeUserNotExist, err
}
return retVal, "", err
})
}
// @Title 绑定小程序
// @Description 绑定小程序
// / @Param token header string true "认证token"
// @Param code formData string true "小程序用户code"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /BindMiniProgram [post]
func (c *AuthController) BindMiniProgram() {
c.callBindMiniProgram(func(params *tAuthBindMiniProgramParams) (retVal interface{}, errCode string, err error) {
err = weixin.AutherMini.BindMiniProgram(params.Ctx, params.Code)
if err == auth.ErrUserNotExist {
return retVal, model.ErrCodeUserNotExist, err
}
return retVal, "", err
})
}
// @Title 解密小程序数据
// @Description 解密小程序数据
// @Param token header string true "认证token"
// @Param data formData string true "加密数据"
// @Param iv formData string true "iv"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /MiniDecryptData [post]
func (c *AuthController) MiniDecryptData() {
c.callMiniDecryptData(func(params *tAuthMiniDecryptDataParams) (retVal interface{}, errCode string, err error) {
retVal, err = weixin.AutherMini.DecryptData(params.Ctx, params.Data, params.Iv)
return retVal, "", err
})
}