分类名重复不允许创建
This commit is contained in:
@@ -143,7 +143,11 @@ func AddCategory(ctx *jxcontext.Context, cat *model.SkuCategory, userName string
|
|||||||
return nil, errors.New("Level3的分类其父分类必须为Level2分类")
|
return nil, errors.New("Level3的分类其父分类必须为Level2分类")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if catsByName, err := dao.GetCategoriesByName(db, cat.Name); err == nil && len(catsByName) > 0 {
|
||||||
|
return nil, fmt.Errorf("已有分类名:[%v],分类名不允许重复!", cat.Name)
|
||||||
|
} else if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
dao.WrapAddIDCULDEntity(cat, userName)
|
dao.WrapAddIDCULDEntity(cat, userName)
|
||||||
// cat.JdSyncStatus = model.SyncFlagNewMask
|
// cat.JdSyncStatus = model.SyncFlagNewMask
|
||||||
// cat.JdID = 0
|
// cat.JdID = 0
|
||||||
|
|||||||
@@ -50,6 +50,21 @@ func DeleteSkuNamePlace(db *DaoDB, nameID int, placeCodes []int) (num int64, err
|
|||||||
return ExecuteSQL(db, sql, sqlParams...)
|
return ExecuteSQL(db, sql, sqlParams...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetCategoriesByName(db *DaoDB, name string) (cats []*model.SkuCategory, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT t1.*
|
||||||
|
FROM sku_category t1
|
||||||
|
WHERE t1.deleted_at = ?`
|
||||||
|
params := []interface{}{
|
||||||
|
utils.DefaultTimeValue,
|
||||||
|
}
|
||||||
|
if name != "" {
|
||||||
|
sql += " AND t1.name = ?"
|
||||||
|
params = append(params, name)
|
||||||
|
}
|
||||||
|
return cats, GetRows(db, &cats, sql, params)
|
||||||
|
}
|
||||||
|
|
||||||
func GetCategories(db *DaoDB, parentID, level int, catIDs []int, isExd bool) (cats []*model.SkuCategory, err error) {
|
func GetCategories(db *DaoDB, parentID, level int, catIDs []int, isExd bool) (cats []*model.SkuCategory, err error) {
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t1.*
|
SELECT t1.*
|
||||||
|
|||||||
Reference in New Issue
Block a user