Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
aa4f7485
authored
Feb 19, 2021
by
hcy001
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
更新分页查询
parent
4a7f6a13
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
service/optimum_service.go
service/optimum_service.go
View file @
aa4f7485
...
...
@@ -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
total
Page
>
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
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment