fix: remove username and nickname field for updating user info

This commit is contained in:
RockYang
2023-09-07 15:41:01 +08:00
parent 590d9c2e61
commit 0e31726fd3
2 changed files with 3 additions and 14 deletions

View File

@@ -62,10 +62,8 @@ func (h *UserHandler) List(c *gin.Context) {
func (h *UserHandler) Save(c *gin.Context) {
var data struct {
Id uint `json:"id"`
Username string `json:"username"`
Password string `json:"password"`
Mobile string `json:"mobile"`
Nickname string `json:"nickname"`
Calls int `json:"calls"`
ImgCalls int `json:"img_calls"`
ChatRoles []string `json:"chat_roles"`
@@ -83,7 +81,6 @@ func (h *UserHandler) Save(c *gin.Context) {
user.Id = data.Id
// 此处需要用 map 更新,用结构体无法更新 0 值
res = h.db.Model(&user).Updates(map[string]interface{}{
"nickname": data.Nickname,
"mobile": data.Mobile,
"calls": data.Calls,
"img_calls": data.ImgCalls,