70 lines
2.6 KiB
Go
70 lines
2.6 KiB
Go
package controllers
|
||
|
||
import (
|
||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||
"git.rosy.net.cn/jx-callback/business/model"
|
||
"github.com/astaxie/beego"
|
||
)
|
||
|
||
type User2Controller struct {
|
||
beego.Controller
|
||
}
|
||
|
||
// @Title 用户注册
|
||
// @Description 用户注册
|
||
// @Param payload formData string true "json数据,User对象(手机号必填)"
|
||
// @Param mobileVerifyCode formData string true "手机验证码(通过auth2.SendVerifyCode获得)"
|
||
// @Param authToken formData string false "之前通过login得到的认证TOKEN(可以为空)"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /RegisterUser [post]
|
||
func (c *User2Controller) RegisterUser() {
|
||
c.callRegisterUser(func(params *tUser2RegisterUserParams) (retVal interface{}, errCode string, err error) {
|
||
var (
|
||
user model.User
|
||
inAuthInfo *auth2.AuthInfo
|
||
)
|
||
if params.AuthToken != "" {
|
||
inAuthInfo, err = auth2.GetTokenInfo(params.AuthToken)
|
||
}
|
||
if err == nil {
|
||
if err = jxutils.Strings2Objs(params.Payload, &user); err == nil {
|
||
retVal, errCode, err = cms.RegisterUser(&user, params.MobileVerifyCode, inAuthInfo)
|
||
}
|
||
}
|
||
return retVal, errCode, err
|
||
})
|
||
}
|
||
|
||
// @Title 得到用户已经成功绑定的认证信息
|
||
// @Description 得到用户已经成功绑定的认证信息
|
||
// @Param token header string true "认证token"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetBindAuthInfo [get]
|
||
func (c *User2Controller) GetBindAuthInfo() {
|
||
c.callGetBindAuthInfo(func(params *tUser2GetBindAuthInfoParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.GetUserBindAuthInfo(params.Ctx)
|
||
return retVal, "", err
|
||
})
|
||
}
|
||
|
||
// @Title 得到用户列表
|
||
// @Description 得到用户列表
|
||
// @Param token header string true "认证token"
|
||
// @Param userType query int true "用户类型"
|
||
// @Param userID2 query string faslse "用户id2"
|
||
// @Param mobile query string faslse "用户手机,必须全匹配"
|
||
// @Param userName query string faslse "用户名,可以部分匹配"
|
||
// @Success 200 {object} controllers.CallResult
|
||
// @Failure 200 {object} controllers.CallResult
|
||
// @router /GetUsers [get]
|
||
func (c *User2Controller) GetUsers() {
|
||
c.callGetUsers(func(params *tUser2GetUsersParams) (retVal interface{}, errCode string, err error) {
|
||
retVal, err = cms.GetUsers(params.Ctx, params.UserType, params.UserID2, params.Mobile, params.UserName)
|
||
return retVal, "", err
|
||
})
|
||
}
|