Browse Source

update: service/system/sys_dictionary.go UpdateSysDictionary 方法 代码优化

main
SliverHorn 3 years ago
parent
commit
011cb40fdf
  1. 9
      server/service/system/sys_dictionary.go

9
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
}

Loading…
Cancel
Save