update set user avatar

This commit is contained in:
aichy126 2022-10-28 15:21:23 +08:00
parent 90deaf027b
commit 9b6a35d88b
5 changed files with 10 additions and 4 deletions

View File

@ -86,6 +86,8 @@ error:
other: "username is invalid"
username_duplicate:
other: "username is already in use"
set_avatar:
other: "avatar set failure"
report:
spam:

View File

@ -86,6 +86,8 @@ error:
other: "用户名无效"
username_duplicate:
other: "用户名已被使用"
set_avatar:
other: "头像设置错误"
report:
spam:

View File

@ -26,6 +26,7 @@ const (
UserNotFound = "error.user.not_found"
UsernameInvalid = "error.user.username_invalid"
UsernameDuplicate = "error.user.username_duplicate"
UserSetAvatar = "error.user.set_avatar"
EmailDuplicate = "error.email.duplicate"
EmailVerifyUrlExpired = "error.email.verify_url_expired"
EmailNeedToBeVerified = "error.email.need_to_be_verified"

View File

@ -82,12 +82,12 @@ func (r *GetUserResp) GetFromUserEntity(userInfo *entity.User) {
}
}
func (us *GetUserResp) AvatarInfo(AvatarJson string) string {
if AvatarJson == "" {
func (us *GetUserResp) AvatarInfo(avatarJson string) string {
if avatarJson == "" {
return ""
}
AvatarInfo := &AvatarInfo{}
err := json.Unmarshal([]byte(AvatarJson), AvatarInfo)
err := json.Unmarshal([]byte(avatarJson), AvatarInfo)
if err != nil {
log.Error("AvatarInfo json.Unmarshal Error", err)
return ""

View File

@ -258,6 +258,7 @@ func (us *UserService) UpdateInfo(ctx context.Context, req *schema.UpdateInfoReq
}
Avatar, err := json.Marshal(req.Avatar)
if err != nil {
err = errors.BadRequest(reason.UserSetAvatar).WithError(err).WithStack()
return err
}
userInfo := entity.User{}
@ -548,7 +549,7 @@ func (us *UserService) UserChangeEmailVerify(ctx context.Context, content string
}
err = us.userRepo.UpdateEmail(ctx, data.UserID, data.Email)
if err != nil {
return err
return errors.BadRequest(reason.UserNotFound)
}
return nil
}