diff --git a/business/jxstore/cms/sku.go b/business/jxstore/cms/sku.go index c75624f14..c7a656c23 100644 --- a/business/jxstore/cms/sku.go +++ b/business/jxstore/cms/sku.go @@ -22,11 +22,11 @@ var ( ) // parentID 为-1表示所有 -func GetVendorCategories(vendorID int, parentID int) (vendorCats []*model.SkuVendorCategory, err error) { +func GetVendorCategories(vendorID int, parentID string) (vendorCats []*model.SkuVendorCategory, err error) { cond := map[string]interface{}{ model.FieldVendorID: vendorID, } - if parentID != -1 { + if parentID != "-1" { cond[model.FieldParentID] = parentID } return vendorCats, dao.GetEntities(nil, &vendorCats, cond, false) diff --git a/business/model/sku.go b/business/model/sku.go index 87e45d074..3c6c978c9 100644 --- a/business/model/sku.go +++ b/business/model/sku.go @@ -113,7 +113,7 @@ type SkuVendorCategory struct { Name string `orm:"size(255);index" json:"name"` IsLeaf int8 `json:"isLeaf"` Level int `json:"level"` - ParentID string `orm:"column(parent_id);size(255);index" json:"parentID"` // 父ID,引用的是VendorCategoryID而不是ID + ParentID string `orm:"column(parent_id);size(48);index" json:"parentID"` // 父ID,引用的是VendorCategoryID而不是ID } func (*SkuVendorCategory) TableUnique() [][]string { diff --git a/controllers/cms_sku.go b/controllers/cms_sku.go index a45a54d92..838cc6fe4 100644 --- a/controllers/cms_sku.go +++ b/controllers/cms_sku.go @@ -15,15 +15,12 @@ type SkuController struct { // @Description 得到厂商商品类别(区别于商家SKU类别) // @Param token header string true "认证token" // @Param vendorID query int true "厂商ID" -// @Param parentID query int false "父ID,-1表示所有,缺省为-1" +// @Param parentID query string false "父ID,-1表示所有,缺省为空" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /GetVendorCategories [get] func (c *SkuController) GetVendorCategories() { c.callGetVendorCategories(func(params *tSkuGetVendorCategoriesParams) (retVal interface{}, errCode string, err error) { - if c.GetString("parentID") == "" { - params.ParentID = -1 - } retVal, err = cms.GetVendorCategories(params.VendorID, params.ParentID) return retVal, "", err })