去除昵称补全
This commit is contained in:
parent
f2e66b65b7
commit
f66d50d142
@ -7,6 +7,7 @@ import (
|
|||||||
"hepa-calc-api/api/requests"
|
"hepa-calc-api/api/requests"
|
||||||
"hepa-calc-api/api/responses"
|
"hepa-calc-api/api/responses"
|
||||||
"hepa-calc-api/api/service"
|
"hepa-calc-api/api/service"
|
||||||
|
"hepa-calc-api/extend/app"
|
||||||
"hepa-calc-api/global"
|
"hepa-calc-api/global"
|
||||||
"hepa-calc-api/utils"
|
"hepa-calc-api/utils"
|
||||||
)
|
)
|
||||||
@ -112,6 +113,64 @@ func (r *User) PutUser(c *gin.Context) {
|
|||||||
responses.Ok(c)
|
responses.Ok(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PutBindUserName 绑定用户数据-昵称
|
||||||
|
func (r *User) PutBindUserName(c *gin.Context) {
|
||||||
|
userRequest := requests.UserRequest{}
|
||||||
|
req := userRequest.PutBindUserName
|
||||||
|
if err := c.ShouldBind(&req); err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 参数验证
|
||||||
|
if err := global.Validate.Struct(req); err != nil {
|
||||||
|
responses.FailWithMessage(utils.Translate(err), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
userId := c.GetInt64("UserId")
|
||||||
|
|
||||||
|
// 获取用户数据
|
||||||
|
userDao := dao.UserDao{}
|
||||||
|
user, err := userDao.GetUserById(userId)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage("用户数据错误", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Mobile == "" {
|
||||||
|
responses.FailWithMessage("用户数据错误", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Nickname == user.UserName {
|
||||||
|
responses.Ok(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取app用户数据
|
||||||
|
appUserInfo, err := app.GetInfoByMobile(user.Mobile)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
userData := make(map[string]interface{})
|
||||||
|
|
||||||
|
// 姓名
|
||||||
|
if appUserInfo.Data.Name != "" {
|
||||||
|
if user.UserName != "" {
|
||||||
|
if appUserInfo.Data.Name != user.UserName {
|
||||||
|
userData["user_name"] = appUserInfo.Data.Name
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
userData["user_name"] = appUserInfo.Data.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
responses.Ok(c)
|
||||||
|
}
|
||||||
|
|
||||||
// GetUserCheck 检测用户数据绑定状态
|
// GetUserCheck 检测用户数据绑定状态
|
||||||
func (r *User) GetUserCheck(c *gin.Context) {
|
func (r *User) GetUserCheck(c *gin.Context) {
|
||||||
userRequest := requests.UserRequest{}
|
userRequest := requests.UserRequest{}
|
||||||
@ -149,7 +208,6 @@ func (r *User) GetUserCheck(c *gin.Context) {
|
|||||||
if err != nil || user == nil {
|
if err != nil || user == nil {
|
||||||
g.WxStatus = 0
|
g.WxStatus = 0
|
||||||
g.MobileStatus = 0
|
g.MobileStatus = 0
|
||||||
g.NameStatus = 0
|
|
||||||
responses.OkWithData(g, c)
|
responses.OkWithData(g, c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -159,10 +217,6 @@ func (r *User) GetUserCheck(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.UserName != "" {
|
|
||||||
g.NameStatus = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if user.Mobile != "" {
|
if user.Mobile != "" {
|
||||||
g.MobileStatus = 1
|
g.MobileStatus = 1
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,6 @@ type UserDto struct {
|
|||||||
type UserCheckDto struct {
|
type UserCheckDto struct {
|
||||||
WxStatus int `json:"wx_status"` // 微信绑定状态(0:否 1:是)
|
WxStatus int `json:"wx_status"` // 微信绑定状态(0:否 1:是)
|
||||||
MobileStatus int `json:"mobile_status"` // 手机号绑定状态(0:否 1:是)
|
MobileStatus int `json:"mobile_status"` // 手机号绑定状态(0:否 1:是)
|
||||||
NameStatus int `json:"name_status"` // 昵称填写状态(0:否 1:是)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserDto 详情
|
// GetUserDto 详情
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user