Commit aa4f7485 by hcy001

更新分页查询

parent 4a7f6a13
Showing with 10 additions and 5 deletions
......@@ -2,6 +2,7 @@ package service
import (
"github.com/gin-gonic/gin"
"github.com/gogf/gf/util/gconv"
"github.com/gomodule/redigo/redis"
"github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
......@@ -168,8 +169,12 @@ func (qs *OptimumService) GetOptimumAttr(ctx *gin.Context) (results model.LyResp
返回供应商详情
*/
func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.LyResponse) {
//fmt.Print(common.NumberToHtml(gconv.Int(ctx.Request.FormValue("d"))))
//修复分页数据
if gconv.Int64(ctx.Request.FormValue("page")) * gconv.Int64(ctx.Request.FormValue("page_size")) >= 10000 {
results.ErrorCode = 0;
results.ErrorMsg = "查询es没有数据,分页查询不得超出10000条"
return
}
//索引字典
qs.getQueryAttr(ctx)
//获取查询条件
......@@ -204,7 +209,6 @@ func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.Ly
attrs[goods_id] = temp
}
//判断返回总条数
total := gjson.Get(esResult, "hits.total").Int()
if total == 0 {
......@@ -213,6 +217,7 @@ func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.Ly
return
}
//拼接返回数据
A := orderedmap.New() //初始化有序map,拼接data 数据
results.ErrorCode = 0;
......@@ -296,8 +301,8 @@ func PageClear(ctx *gin.Context,total int64) map[string]interface{}{
page["total"] = strconv.FormatInt(total,10)
page["current_page"] = p
page["offset"] = page_size
if totalPage > 1000{
page["total_page"] = "1000"
if total == 10000 {
page["total_page"] = math.Ceil(float64(total)/common.MyFloat64(page_size))
}else{
page["total_page"] = strconv.FormatInt(int64(totalPage),10)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment