- GetCategories order by level, seq
This commit is contained in:
@@ -34,10 +34,14 @@ func GetVendorCategories(vendorID int, parentID string) (vendorCats []*model.Sku
|
||||
|
||||
// parentID 为-1表示所有
|
||||
func GetCategories(parentID int) (cats []*model.SkuCategory, err error) {
|
||||
if parentID == -1 {
|
||||
return cats, dao.GetEntities(nil, &cats, nil, false)
|
||||
params := []interface{}{}
|
||||
sql := "SELECT * FROM sku_category WHERE deleted_at = '1970-01-01 00:00:00' "
|
||||
if parentID != -1 {
|
||||
sql += " AND parent_id = ?"
|
||||
params = append(params, parentID)
|
||||
}
|
||||
return cats, dao.GetEntities(nil, &cats, utils.Params2Map(model.FieldParentID, parentID), false)
|
||||
sql += " ORDER BY level, seq"
|
||||
return cats, dao.GetRows(nil, &cats, sql, params)
|
||||
}
|
||||
|
||||
func AddCategory(cat *model.SkuCategory, userName string) (outCat *model.SkuCategory, err error) {
|
||||
|
||||
Reference in New Issue
Block a user