This commit is contained in:
wucongxing8150 2024-08-23 13:24:28 +08:00
parent 3f2dae8364
commit d40aafe627
3 changed files with 22 additions and 3 deletions

View File

@ -32,17 +32,24 @@ func (r *User) GetUser(c *gin.Context) {
// 获取用户详情
userInfoDao := dao.UserInfoDao{}
_, err = userInfoDao.GetUserInfoByUserId(userId)
userInfo, err := userInfoDao.GetUserInfoByUserId(userId)
if err != nil || user == nil {
responses.FailWithMessage("用户数据错误", c)
return
}
// 检测用户信息是否补全
userService := service.UserService{}
IsCompleteInfo := userService.CheckUserInfo(userInfo)
g := dto.GetUserDto(user)
// 加载数据-生日
g.LoadBirthday(user.Birthday)
// 加载用户信息是否补全
g.IsCompleteInfo = IsCompleteInfo
responses.OkWithData(g, c)
}

View File

@ -26,6 +26,7 @@ type UserDto struct {
LoginIp string `json:"login_ip"` // 登陆ip
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
IsCompleteInfo bool `json:"Is_complete_info"` // 信息是否完整0:否 1:是)
}
// UserCheckDto 检测用户

View File

@ -682,9 +682,13 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
appData.Sex = &sex
}
if user.Sex != nil {
if req.Sex != *user.Sex {
userData["sex"] = req.Sex
}
} else {
userData["sex"] = req.Sex
}
// 头像
if req.Avatar != "" {
@ -928,6 +932,13 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
}
// CheckUserInfo 检测用户信息是否补全
func (r *UserService) CheckUserInfo(userId int64) bool {
func (r *UserService) CheckUserInfo(userInfo *model.UserInfo) bool {
if userInfo == nil {
return false
}
if userInfo.Height == "" {
return false
}
return false
}