查询goodslist微盟api修改

This commit is contained in:
苏尹岚
2019-11-11 09:59:47 +08:00
parent 7dde83f600
commit 967fb1c16a

View File

@@ -96,18 +96,31 @@ type GoodsInfo struct {
Title string `json:"title"`
}
func (a *API) QueryGoodsList(pageNum, pageSize int, orderBy []map[string]interface{}, queryParameter map[string]interface{}) (goodsList []*GoodsInfo, totalCount int, err error) {
apiParams := map[string]interface{}{
"pageNum": pageNum,
"pageSize": pageSize,
type QueryGoodsListParam struct {
PageNum int `json:"pageNum"`
PageSize int `json:"pageSize"`
OrderBy
GoodsParameter
}
type OrderBy struct {
Field string `json:"field"` //排序字段名: sortNum按照sort字段排序 putAwayDate按照上下架时间排序 salesNum按照销量排序 availableStockNum按照库存排序 price按照价格排序
Sort string `json:"sort"` //升降/降序 DESC/ASC只能是这两个值不区分大小写
}
type GoodsParameter struct {
GoodsStatus int `json:"goodsStatus"` //商品状态0-上架中 1-下架中 2-已售罄
GoodsClassifyID int `json:"goodsClassifyId"` //分组id
Search string `json:"search"` //搜索框输入内容商品名称
GoodsPrice float32 `json:"goodsPrice"`
}
func (a *API) QueryGoodsList(queryParam *QueryGoodsListParam) (goodsList []*GoodsInfo, totalCount int, err error) {
param := make(map[string]interface{})
if queryParam != nil {
param = utils.Struct2FlatMap(queryParam)
}
if orderBy != nil {
apiParams["orderBy"] = orderBy
}
if queryParameter != nil {
apiParams["queryParameter"] = queryParameter
}
result, err := a.AccessAPI("goods/queryGoodsList", apiParams)
result, err := a.AccessAPI("goods/queryGoodsList", param)
if err == nil {
data := result.(map[string]interface{})
totalCount = int(utils.MustInterface2Int64(data["totalCount"]))