修改登录,新增openid判断
This commit is contained in:
parent
0a88515bc6
commit
1e3bc3b3dc
@ -32,7 +32,7 @@ func (r *Login) Login(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.OpenId == "" && req.Mobile == "" {
|
||||
if req.Mobile == "" {
|
||||
responses.FailWithMessage("登陆失败", c)
|
||||
return
|
||||
}
|
||||
@ -78,17 +78,7 @@ func (r *Login) Login(c *gin.Context) {
|
||||
// 检测用户信息
|
||||
userDao := dao.UserDao{}
|
||||
maps := make(map[string]interface{})
|
||||
if req.OpenId != "" {
|
||||
maps["open_id"] = req.OpenId
|
||||
}
|
||||
|
||||
if req.Mobile != "" {
|
||||
maps["mobile"] = req.Mobile
|
||||
}
|
||||
|
||||
if req.Uuid != "" {
|
||||
maps["app_iden"] = req.Uuid
|
||||
}
|
||||
maps["mobile"] = req.Mobile
|
||||
user, _ := userDao.GetUser(maps)
|
||||
// 新用户处理方式
|
||||
if user == nil {
|
||||
@ -164,6 +154,21 @@ func (r *Login) Login(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理用户openid
|
||||
if req.OpenId != "" {
|
||||
userData := make(map[string]interface{})
|
||||
if req.OpenId != user.OpenId {
|
||||
userData["open_id"] = req.OpenId
|
||||
}
|
||||
|
||||
err := userDao.EditUserById(tx, user.UserId, userData)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 处理app用户数据
|
||||
userService := service.UserService{}
|
||||
err = userService.GetAppUserInfo(tx, user, userInfo)
|
||||
|
||||
@ -219,6 +219,7 @@ func (r *User) GetUserCheck(c *gin.Context) {
|
||||
|
||||
if user.Mobile != "" {
|
||||
g.MobileStatus = 1
|
||||
g.Mobile = user.Mobile
|
||||
}
|
||||
|
||||
if user.OpenId != "" {
|
||||
|
||||
@ -31,8 +31,9 @@ type UserDto struct {
|
||||
|
||||
// UserCheckDto 检测用户
|
||||
type UserCheckDto struct {
|
||||
WxStatus int `json:"wx_status"` // 微信绑定状态(0:否 1:是)
|
||||
MobileStatus int `json:"mobile_status"` // 手机号绑定状态(0:否 1:是)
|
||||
WxStatus int `json:"wx_status"` // 微信绑定状态(0:否 1:是)
|
||||
MobileStatus int `json:"mobile_status"` // 手机号绑定状态(0:否 1:是)
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
}
|
||||
|
||||
// GetUserDto 详情
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user