修改登录,新增openid判断

This commit is contained in:
wucongxing8150 2024-09-05 13:14:55 +08:00
parent 0a88515bc6
commit 1e3bc3b3dc
3 changed files with 21 additions and 14 deletions

View File

@ -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)

View File

@ -219,6 +219,7 @@ func (r *User) GetUserCheck(c *gin.Context) {
if user.Mobile != "" {
g.MobileStatus = 1
g.Mobile = user.Mobile
}
if user.OpenId != "" {

View File

@ -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 详情