fixed phone binding always error

pull/150/head
alimy 3 years ago
parent 50c344cc02
commit cabc4e3552

@ -205,9 +205,7 @@ func ChangeAvatar(c *gin.Context) {
return
}
// 执行绑定
user.Avatar = param.Avatar
if err := service.UpdateUserInfo(user); err != nil {
if err := service.ChangeUserAvatar(user, param.Avatar); err != nil {
response.ToErrorResponse(err)
return
}

@ -261,16 +261,20 @@ func GetUserByUsername(username string) (*model.User, error) {
// UpdateUserInfo 更新用户信息
func UpdateUserInfo(user *model.User) *errcode.Error {
err := ds.CheckAttachment(user.Avatar)
if err != nil {
return errcode.InvalidParams
}
if err = ds.UpdateUser(user); err != nil {
if err := ds.UpdateUser(user); err != nil {
return errcode.ServerError
}
return nil
}
func ChangeUserAvatar(user *model.User, avatar string) *errcode.Error {
if err := ds.CheckAttachment(avatar); err != nil {
return errcode.InvalidParams
}
user.Avatar = avatar
return UpdateUserInfo(user)
}
// GetUserCollections 获取用户收藏列表
func GetUserCollections(userID int64, offset, limit int) ([]*model.PostFormated, int64, error) {
collections, err := ds.GetUserPostCollections(userID, offset, limit)

Loading…
Cancel
Save