From 011cb40fdfc74d4f020512ff94386a156f13b5ac Mon Sep 17 00:00:00 2001 From: SliverHorn Date: Sat, 4 Sep 2021 22:59:13 +0800 Subject: [PATCH] =?UTF-8?q?update:=20service/system/sys=5Fdictionary.go=20?= =?UTF-8?q?UpdateSysDictionary=20=E6=96=B9=E6=B3=95=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/service/system/sys_dictionary.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/server/service/system/sys_dictionary.go b/server/service/system/sys_dictionary.go index 1335218d..37f05b69 100644 --- a/server/service/system/sys_dictionary.go +++ b/server/service/system/sys_dictionary.go @@ -52,15 +52,12 @@ func (dictionaryService *DictionaryService) UpdateSysDictionary(sysDictionary *s "Desc": sysDictionary.Desc, } db := global.GVA_DB.Where("id = ?", sysDictionary.ID).First(&dict) - if dict.Type == sysDictionary.Type { - err = db.Updates(sysDictionaryMap).Error - } else { - if (!errors.Is(global.GVA_DB.First(&system.SysDictionary{}, "type = ?", sysDictionary.Type).Error, gorm.ErrRecordNotFound)) { + if dict.Type != sysDictionary.Type { + if !errors.Is(global.GVA_DB.First(&system.SysDictionary{}, "type = ?", sysDictionary.Type).Error, gorm.ErrRecordNotFound) { return errors.New("存在相同的type,不允许创建") } - err = db.Updates(sysDictionaryMap).Error - } + err = db.Updates(sysDictionaryMap).Error return err }