Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbbbbbbbbbbba committed Sep 27, 2022
1 parent 1451219 commit 5800051
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions server/controllers/api/user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (c *UserController) PostEditBy(userId int64) *web.JsonResult {
description = params.FormValue(c.Ctx, "description")
gender = strings.TrimSpace(params.FormValue(c.Ctx, "gender"))
birthdayStr = strings.TrimSpace(params.FormValue(c.Ctx, "birthday"))
birthday time.Time
birthday *time.Time
err error
)

Expand All @@ -73,7 +73,7 @@ func (c *UserController) PostEditBy(userId int64) *web.JsonResult {
}
}
if strs.IsNotBlank(birthdayStr) {
birthday, err = dates.Parse(birthdayStr, dates.FmtDate)
*birthday, err = dates.Parse(birthdayStr, dates.FmtDate)
if err != nil {
return web.JsonError(err)
}
Expand All @@ -83,13 +83,16 @@ func (c *UserController) PostEditBy(userId int64) *web.JsonResult {
return web.JsonErrorMsg("个人主页地址错误")
}

err = services.UserService.Updates(user.Id, map[string]interface{}{
columns := map[string]interface{}{
"nickname": nickname,
"home_page": homePage,
"description": description,
"gender": gender,
"birthday": birthday,
})
}
if birthday != nil {
columns["birthday"] = birthday
}
err = services.UserService.Updates(user.Id, columns)
if err != nil {
return web.JsonError(err)
}
Expand Down

0 comments on commit 5800051

Please sign in to comment.