From 5cf93aff63a445051c5317653f25a5e9dd10c841 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 09 四月 2024 16:18:21 +0800 Subject: [PATCH] fix --- controllers/dict.go | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/controllers/dict.go b/controllers/dict.go index cd22412..ef51e3f 100644 --- a/controllers/dict.go +++ b/controllers/dict.go @@ -88,19 +88,19 @@ } func (slf DictController) ParamsCheck(params models.Dict) (err error) { - if params.Number == "" || params.Name == "" { + if params.Name == "" { return errors.New("鍙傛暟缂哄け") } - dict, err := models.NewDictSearch().SetNumber(params.Number).First() - if err != gorm.ErrRecordNotFound && dict != nil && dict.ID != params.ID { - return errors.New("缂栧彿閲嶅") - } - - dict, err = models.NewDictSearch().SetName(params.Name).First() + dict, err := models.NewDictSearch().SetName(params.Name).First() if err != gorm.ErrRecordNotFound && dict != nil && dict.ID != params.ID { return errors.New("鍚嶇О閲嶅") } - + if params.Number != "" { + dict, err := models.NewDictSearch().SetDictType(params.DictType).SetNumber(params.Number).First() + if err != gorm.ErrRecordNotFound && dict != nil && dict.ID != params.ID { + return errors.New("缂栧彿閲嶅") + } + } return nil } -- Gitblit v1.8.0