作者 yangfu

商品分页

@@ -26,8 +26,11 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte @@ -26,8 +26,11 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte
26 if _, ok := queryOptions["beginTime"]; ok { 26 if _, ok := queryOptions["beginTime"]; ok {
27 queryTime = fmt.Sprintf("and created_at>='%v' and created_at<'%v'", queryOptions["beginTime"], queryOptions["endTime"]) 27 queryTime = fmt.Sprintf("and created_at>='%v' and created_at<'%v'", queryOptions["beginTime"], queryOptions["endTime"])
28 } 28 }
29 - if _, ok := queryOptions["limit"]; ok {  
30 - queryLimit = fmt.Sprintf("limit %v", queryOptions["limit"]) 29 + if v, ok := queryOptions["offset"]; ok {
  30 + queryLimit += fmt.Sprintf("offset %v \n", v)
  31 + }
  32 + if v, ok := queryOptions["limit"]; ok {
  33 + queryLimit += fmt.Sprintf("limit %v \n", v)
31 } 34 }
32 sql := fmt.Sprintf(`select order_good_name good_name,sum(coalesce(order_good_amount,0)) good_amount from order_goods 35 sql := fmt.Sprintf(`select order_good_name good_name,sum(coalesce(order_good_amount,0)) good_amount from order_goods
33 where company_id=? and org_id = ? and deleted_at is null %v 36 where company_id=? and org_id = ? and deleted_at is null %v
@@ -27,6 +27,7 @@ func (ptr *CooperationStatisticsService) CooperationGoodsStatistics(queryOptions @@ -27,6 +27,7 @@ func (ptr *CooperationStatisticsService) CooperationGoodsStatistics(queryOptions
27 RankType int `json:"rankType" valid:"Required"` 27 RankType int `json:"rankType" valid:"Required"`
28 Top int `json:"top" valid:"Required"` 28 Top int `json:"top" valid:"Required"`
29 Offset int `json:"offset"` 29 Offset int `json:"offset"`
  30 + Limit int `json:"limit"`
30 }{} 31 }{}
31 if err := LoadQueryObject(queryOptions, &request); err != nil { 32 if err := LoadQueryObject(queryOptions, &request); err != nil {
32 return nil, err 33 return nil, err
@@ -50,6 +51,9 @@ func (ptr *CooperationStatisticsService) CooperationGoodsStatistics(queryOptions @@ -50,6 +51,9 @@ func (ptr *CooperationStatisticsService) CooperationGoodsStatistics(queryOptions
50 if request.Top > 0 { 51 if request.Top > 0 {
51 queryOptions["limit"] = request.Top 52 queryOptions["limit"] = request.Top
52 } 53 }
  54 + if request.Limit > 0 {
  55 + queryOptions["limit"] = request.Limit
  56 + }
53 if request.Offset > 0 { 57 if request.Offset > 0 {
54 queryOptions["offset"] = request.Offset 58 queryOptions["offset"] = request.Offset
55 } 59 }