- sku category man almost ok.

- mysql connect str add utf8mb4.
This commit is contained in:
gazebo
2018-09-09 20:43:48 +08:00
parent d71b0e6763
commit d8907cf010
14 changed files with 304 additions and 41 deletions

View File

@@ -1,7 +1,9 @@
package controllers
import (
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
"git.rosy.net.cn/jx-callback/business/model"
"github.com/astaxie/beego"
)
@@ -13,12 +15,16 @@ 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"
// @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) {
retVal, err = cms.GetVendorCategories(params.VendorID)
if c.GetString("parentID") == "" {
params.ParentID = -1
}
retVal, err = cms.GetVendorCategories(params.VendorID, params.ParentID)
return retVal, "", err
})
}
@@ -35,3 +41,73 @@ func (c *SkuController) GetSkuMetaInfo() {
return retVal, "", err
})
}
// @Title 得到商品类别
// @Description 得到商品类别区别于厂商家SKU类别
// @Param token header string true "认证token"
// @Param parentID query int false "父ID-1表示所有缺省为-1"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetCategories [get]
func (c *SkuController) GetCategories() {
c.callGetCategories(func(params *tSkuGetCategoriesParams) (retVal interface{}, errCode string, err error) {
if c.GetString("parentID") == "" {
params.ParentID = -1
}
retVal, err = cms.GetCategories(params.ParentID)
return retVal, "", err
})
}
// @Title 新增商品类别
// @Description 新增商品类别区别于厂商家SKU类别
// @Param token header string true "认证token"
// @Param payload formData string true "json数据skuCategory对象()"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /AddCategory [post]
func (c *SkuController) AddCategory() {
c.callAddCategory(func(params *tSkuAddCategoryParams) (retVal interface{}, errCode string, err error) {
cat := &model.SkuCategory{}
if err = utils.UnmarshalUseNumber([]byte(params.Payload), cat); err == nil {
retVal, err = cms.AddCategory(cat, GetUserNameFromToken(params.Token))
}
return retVal, "", err
})
}
// @Title 修改商品类别
// @Description 修改商品类别区别于厂商家SKU类别
// @Param token header string true "认证token"
// @Param categoryID formData int true "类别IDpayload中的相应字段会被忽略"
// @Param payload formData string true "json数据skuCategory对象()"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /UpdateCategory [put]
func (c *SkuController) UpdateCategory() {
c.callUpdateCategory(func(params *tSkuUpdateCategoryParams) (retVal interface{}, errCode string, err error) {
payload := make(map[string]interface{})
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil {
retVal, err = cms.UpdateCategory(params.CategoryID, payload, GetUserNameFromToken(params.Token))
}
return retVal, "", err
})
}
// @Title 商品类别重排序
// @Description 商品类别重排序区别于厂商家SKU类别
// @Param token header string true "认证token"
// @Param categoryID formData int true "父ID"
// @Param ids formData string true "同一父类别下的所有子类别ID列表([1,2,3,4])"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /ReorderCategories [put]
func (c *SkuController) ReorderCategories() {
c.callReorderCategories(func(params *tSkuReorderCategoriesParams) (retVal interface{}, errCode string, err error) {
var idList []int
if err = utils.UnmarshalUseNumber([]byte(params.Ids), &idList); err == nil {
err = cms.ReorderCategories(params.CategoryID, idList, GetUserNameFromToken(params.Token))
}
return retVal, "", err
})
}