饿鲜达分类查询初尝试
This commit is contained in:
@@ -58,9 +58,9 @@ func GetVendorCategories(ctx *jxcontext.Context, vendorID int, parentID string)
|
||||
}
|
||||
|
||||
// parentID 为-1表示所有
|
||||
func GetCategories(ctx *jxcontext.Context, parentID int) (catList []*dao.SkuCategoryWithVendor, err error) {
|
||||
func GetCategories(ctx *jxcontext.Context, parentID int, isExd bool) (catList []*dao.SkuCategoryWithVendor, err error) {
|
||||
db := dao.GetDB()
|
||||
cats, err := dao.GetCategories(db, parentID, 0, nil)
|
||||
cats, err := dao.GetCategories(db, parentID, 0, nil, isExd)
|
||||
if err == nil {
|
||||
var ids []int
|
||||
for _, v := range cats {
|
||||
|
||||
@@ -2435,7 +2435,7 @@ func GetTopCategoriesByStoreIDs(ctx *jxcontext.Context, storeIDs []int) (skuCate
|
||||
}
|
||||
//推荐分类,若不满10个,则填满10个
|
||||
if (len(skuCategory) < limit && len(skuCategory) > 0) || len(skuCategory) == 0 {
|
||||
skuCategory2, err = dao.GetCategories(db, -1, 1, nil)
|
||||
skuCategory2, err = dao.GetCategories(db, -1, 1, nil, false)
|
||||
if len(skuCategory2) > 0 {
|
||||
for _, v := range skuCategory2 {
|
||||
if skuCategoryMap[v.ID] == nil {
|
||||
|
||||
@@ -47,7 +47,7 @@ func DeleteSkuNamePlace(db *DaoDB, nameID int, placeCodes []int) (num int64, err
|
||||
return ExecuteSQL(db, sql, sqlParams...)
|
||||
}
|
||||
|
||||
func GetCategories(db *DaoDB, parentID, level int, catIDs []int) (cats []*model.SkuCategory, err error) {
|
||||
func GetCategories(db *DaoDB, parentID, level int, catIDs []int, isExd bool) (cats []*model.SkuCategory, err error) {
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
FROM sku_category t1
|
||||
@@ -67,7 +67,11 @@ func GetCategories(db *DaoDB, parentID, level int, catIDs []int) (cats []*model.
|
||||
sql += " AND t1.level = ?"
|
||||
params = append(params, level)
|
||||
}
|
||||
sql += " ORDER BY t1.level, t1.seq"
|
||||
if isExd {
|
||||
sql += " ORDER BY t1.level, t1.exd_seq"
|
||||
} else {
|
||||
sql += " ORDER BY t1.level, t1.seq"
|
||||
}
|
||||
return cats, GetRows(db, &cats, sql, params)
|
||||
}
|
||||
|
||||
|
||||
@@ -1156,7 +1156,7 @@ func GetStoreSkuCategories(db *DaoDB, storeID, parentID int) (catList []*model.S
|
||||
for _, v := range catList {
|
||||
parentIDMap[v.ParentID] = 1
|
||||
}
|
||||
paretnCats, err2 := GetCategories(db, -1, 0, jxutils.IntMap2List(parentIDMap))
|
||||
paretnCats, err2 := GetCategories(db, -1, 0, jxutils.IntMap2List(parentIDMap), false)
|
||||
if err = err2; err == nil {
|
||||
catList = append(catList, paretnCats...)
|
||||
} else {
|
||||
|
||||
@@ -33,6 +33,7 @@ func (c *SkuController) GetVendorCategories() {
|
||||
// @Description 得到商品类别(区别于厂商家SKU类别)
|
||||
// @Param token header string false "认证token"
|
||||
// @Param parentID query int false "父ID,-1表示所有,缺省为-1"
|
||||
// @Param isExd query bool false "是否要查饿鲜达分类"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetCategories [get]
|
||||
@@ -41,7 +42,7 @@ func (c *SkuController) GetCategories() {
|
||||
if c.GetString("parentID") == "" {
|
||||
params.ParentID = -1
|
||||
}
|
||||
retVal, err = cms.GetCategories(params.Ctx, params.ParentID)
|
||||
retVal, err = cms.GetCategories(params.Ctx, params.ParentID, params.IsExd)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user