- GetCategories order by level, seq

This commit is contained in:
gazebo
2018-09-18 22:36:29 +08:00
parent cfe296fd6e
commit 6299c1e61f

View File

@@ -34,10 +34,14 @@ func GetVendorCategories(vendorID int, parentID string) (vendorCats []*model.Sku
// parentID 为-1表示所有 // parentID 为-1表示所有
func GetCategories(parentID int) (cats []*model.SkuCategory, err error) { func GetCategories(parentID int) (cats []*model.SkuCategory, err error) {
if parentID == -1 { params := []interface{}{}
return cats, dao.GetEntities(nil, &cats, nil, false) 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) { func AddCategory(cat *model.SkuCategory, userName string) (outCat *model.SkuCategory, err error) {