From 930f0118ba4c5f31961b978c42f37fc727efcd44 Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Mon, 17 Mar 2025 15:02:31 +0800 Subject: [PATCH] cofnig --- server/api/staff.go | 3 +-- server/service/staff_user.go | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/server/api/staff.go b/server/api/staff.go index ff4373f..441c3c2 100644 --- a/server/api/staff.go +++ b/server/api/staff.go @@ -4,7 +4,6 @@ import ( butil "enterprise/base/util" "enterprise/common/model" "fmt" - "github.com/skip2/go-qrcode" "github.com/smbrave/goutil" "github.com/spf13/cast" ) @@ -71,7 +70,7 @@ type StaffUpdateReq struct { PayeeBankCard string `json:"payee_bank_card"` PayeeAlipayUid string `json:"payee_alipay_uid"` - Config map[string]string `json:"config"` + Config string `json:"config"` } func (s *StaffUser) From(m *model.StaffUser) { diff --git a/server/service/staff_user.go b/server/service/staff_user.go index 8c3d682..2d8e55e 100644 --- a/server/service/staff_user.go +++ b/server/service/staff_user.go @@ -169,16 +169,18 @@ func (s *StaffUser) Update(sess *session.AdminSession, req *api.StaffUpdateReq) } } - if len(req.Config) != 0 { - var cfg map[string]interface{} - json.Unmarshal([]byte(staffUser.Config), &cfg) - if cfg == nil { - cfg = make(map[string]interface{}) + if req.Config != "" { + var oldCfg map[string]interface{} + var newCfg map[string]interface{} + json.Unmarshal([]byte(staffUser.Config), &oldCfg) + json.Unmarshal([]byte(req.Config), &newCfg) + if oldCfg == nil { + oldCfg = make(map[string]interface{}) } - for k, v := range req.Config { - cfg[k] = v + for k, v := range newCfg { + oldCfg[k] = v } - staffUser.Config = goutil.EncodeJSON(cfg) + staffUser.Config = goutil.EncodeJSON(oldCfg) } err = dao.NewStaffUserDao().Update(staffUser)