diff --git a/controller/user.go b/controller/user.go index 9532ceb..a897d41 100644 --- a/controller/user.go +++ b/controller/user.go @@ -8,6 +8,7 @@ import ( "electricity_bill_calc/response" "electricity_bill_calc/security" "electricity_bill_calc/service" + "electricity_bill_calc/tools" "fmt" "net/http" "strconv" @@ -326,6 +327,10 @@ func modifyAccountDetail(c *gin.Context) { newUserInfo := new(model.UserDetail) newUserInfo.Id = targetUserId newUserInfo.Name = &modForm.Name + if &modForm.Name != nil { + abbr := tools.PinyinAbbr(*&modForm.Name) + newUserInfo.Abbr = &abbr + } newUserInfo.Region = modForm.Region newUserInfo.Address = modForm.Address newUserInfo.Contact = modForm.Contact @@ -337,7 +342,7 @@ func modifyAccountDetail(c *gin.Context) { } _, err = global.DB.NewUpdate().Model(newUserInfo). WherePK(). - Column("name", "region", "address", "contact", "phone", "unit_service_fee"). + Column("name", "abbr", "region", "address", "contact", "phone", "unit_service_fee"). Exec(c) if err != nil { result.Error(http.StatusInternalServerError, err.Error())