From 710d2857335b0d9af2c007edb8fcc7fd5ef90301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Sun, 18 Sep 2022 11:40:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(user):=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=9C=A8=E4=BF=AE=E6=94=B9=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=EF=BC=8C=E6=8B=BC=E9=9F=B3=E7=BC=A9=E5=86=99=E4=B8=8D?= =?UTF-8?q?=E8=B7=9F=E9=9A=8F=E4=BF=AE=E6=94=B9=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/user.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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())