Commit e17e7658 by huangchengyi

1.0

parent 82129546
The file could not be displayed because it is too large.
...@@ -25,7 +25,12 @@ func GetGoodsInfo(ctx *gin.Context,goodsIds []string) (goodsList []model.ApiGood ...@@ -25,7 +25,12 @@ func GetGoodsInfo(ctx *gin.Context,goodsIds []string) (goodsList []model.ApiGood
"power[newCustomer]": isNewCustomer, "power[newCustomer]": isNewCustomer,
"power[member]": isMember, "power[member]": isMember,
} }
common.PrintDebugHtml(ctx,params)
goodsList, _, err = CurlGoodsInfo(ctx,goodsIdsStr, params) goodsList, _, err = CurlGoodsInfo(ctx,goodsIdsStr, params)
common.PrintDebugHtml(ctx,goodsList)
return return
} }
......
...@@ -73,6 +73,7 @@ eg: ...@@ -73,6 +73,7 @@ eg:
https://ichunt.com/optimum-9987_1.html?ev=brand_12042^2660_128036||128037 https://ichunt.com/optimum-9987_1.html?ev=brand_12042^2660_128036||128037
class_id2=9987 page=1 ev:属性id+属性值id class_id2=9987 page=1 ev:属性id+属性值id
doc: https://www.tapd.cn/20210831/markdown_wikis/show/#1120210831001000440
*/ */
func (qs *OptimumService) GetOptimumAttr(ctx *gin.Context) (results model.LyResponse) { func (qs *OptimumService) GetOptimumAttr(ctx *gin.Context) (results model.LyResponse) {
qs.getQueryAttr(ctx) qs.getQueryAttr(ctx)
...@@ -159,7 +160,7 @@ func (qs *OptimumService) GetOptimumAttr(ctx *gin.Context) (results model.LyResp ...@@ -159,7 +160,7 @@ func (qs *OptimumService) GetOptimumAttr(ctx *gin.Context) (results model.LyResp
} }
A.Set("aggs",aggs) A.Set("aggs",aggs)
results.Data = aggs results.Data = A
return return
} }
...@@ -197,9 +198,9 @@ func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.Ly ...@@ -197,9 +198,9 @@ func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.Ly
A := orderedmap.New() //初始化有序map,拼接data 数据 A := orderedmap.New() //初始化有序map,拼接data 数据
results.ErrorCode = 0; results.ErrorCode = 0;
results.ErrorMsg = "查询成功"; results.ErrorMsg = "查询成功";
page := PageClear(ctx,10,total); page := PageClear(ctx,total);
page["took"] = gjson.Get(esResult, "took").Int() page["took"] = gjson.Get(esResult, "took").Int()
A.Set("page_data",page) //分页信息 A.Set("page",page) //分页信息
//aggs := orderedmap.New() //拼接aggs //aggs := orderedmap.New() //拼接aggs
common.PrintDebugHtml(ctx,goodsIds) common.PrintDebugHtml(ctx,goodsIds)
...@@ -237,39 +238,29 @@ func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.Ly ...@@ -237,39 +238,29 @@ func (qs *OptimumService) GetOptimumAttrInfo(ctx *gin.Context) (results model.Ly
} }
//處理分頁信息 //處理分頁信息
func PageClear(ctx *gin.Context,pagesize int64,hitsTotal int64) map[string]interface{}{ func PageClear(ctx *gin.Context,total int64) map[string]interface{}{
totalPage := math.Ceil(float64(hitsTotal)/float64(pagesize)) page_size := ctx.Request.FormValue("page_size")
var ( if page_size == "" {
total int64 page_size = "10";
offsetInt int }
err error totalPage := math.Ceil(float64(total)/common.MyFloat64(page_size))
)
page := make(map[string]interface{},0) if total > 10000 {
if totalPage > 1{
if hitsTotal > 10000 {
total = 10000 total = 10000
}else{
total = hitsTotal
} }
page := make(map[string]interface{},0)
if totalPage > 1{
p := ctx.Request.FormValue("page") p := ctx.Request.FormValue("page")
if p == ""{ if p == ""{
p = "1" p = "1"
} }
offset := ctx.Request.FormValue("offset")
offsetInt, err = strconv.Atoi(offset)
if err == nil && offsetInt > 0{
offset = strconv.FormatInt(int64(offsetInt),10)
}else{
offsetInt = 10
offset = "10"
}
//如果是自营同步输出 //如果是自营同步输出
//自定義分頁 //自定義分頁
page["orgin_search"] = REQUEST page["orgin_search"] = REQUEST
page["total"] = strconv.FormatInt(total,10) page["total"] = strconv.FormatInt(total,10)
page["current_page"] = p page["current_page"] = p
page["offset"] = offset page["offset"] = page_size
if totalPage > 1000{ if totalPage > 1000{
page["total_page"] = "1000" page["total_page"] = "1000"
}else{ }else{
...@@ -277,6 +268,8 @@ func PageClear(ctx *gin.Context,pagesize int64,hitsTotal int64) map[string]inter ...@@ -277,6 +268,8 @@ func PageClear(ctx *gin.Context,pagesize int64,hitsTotal int64) map[string]inter
} }
pageData := make(map[int]int,0) pageData := make(map[int]int,0)
pInt := int(1) pInt := int(1)
var err error
pInt, err = strconv.Atoi(p) pInt, err = strconv.Atoi(p)
if err != nil{ if err != nil{
pInt = int(1) pInt = int(1)
...@@ -308,7 +301,9 @@ func PageClear(ctx *gin.Context,pagesize int64,hitsTotal int64) map[string]inter ...@@ -308,7 +301,9 @@ func PageClear(ctx *gin.Context,pagesize int64,hitsTotal int64) map[string]inter
} }
page["page_data"] = common.MapSort(pageData) page["page_data"] = common.MapSort(pageData)
}else{ }else{
page["total"] = 1 page["total"] = total
page["total_page"] = totalPage
page["page_data"] = ""
} }
return page return page
} }
\ No newline at end of file
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