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
7fe143a7
authored
Jul 17, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
up
parent
7adf944a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
1 deletions
service/ziyin_service.go
service/ziyin_service.go
View file @
7fe143a7
...
...
@@ -217,15 +217,47 @@ func searchZiYingGoods( req map[string]string,zy bool,classList *model.ZhyClassL
}
//库存排序
if
stock_rank
,
ok
:=
req
[
"stock_rank"
];
ok
&&
stock_rank
!=
""
{
switch
{
case
strings
.
TrimSpace
(
stock_rank
)
==
"1"
:
source
.
Sort
(
"stock"
,
true
)
//desc
case
strings
.
TrimSpace
(
stock_rank
)
==
"2"
:
source
.
Sort
(
"stock"
,
false
)
//asc
}
}
//综合排序
if
com_rank
,
ok
:=
req
[
"com_rank"
];
ok
&&
strings
.
TrimSpace
(
com_rank
)
==
"1"
{
source
.
Sort
(
"sort"
,
true
)
//desc
source
.
Sort
(
"single_price"
,
false
)
//asc
}
}
length
:=
int64
(
10
)
if
offset
,
ok
:=
req
[
"offset"
];
ok
{
if
offsetInt
,
err
:=
strconv
.
ParseInt
(
offset
,
10
,
64
);
err
!=
nil
&&
offsetInt
>
0
{
length
=
offsetInt
}
}
page
:=
int64
(
1
)
if
p
,
ok
:=
req
[
"p"
];
ok
{
if
pInt
,
err
:=
strconv
.
ParseInt
(
p
,
10
,
64
);
err
!=
nil
&&
pInt
>
0
{
page
=
pInt
}
}
start
:=
(
page
-
1
)
*
length
from
:=
start
if
start
+
length
>=
10000
{
from
=
10000
-
length
}
source
.
From
(
int
(
from
))
.
Size
(
int
(
length
))
source
.
Query
(
query
)
res
,
_
:=
elastic
.
NewSearchRequest
()
.
Source
(
source
)
.
Body
()
fmt
.
Println
(
res
)
}
func
makeQuery
(
query
*
elastic
.
BoolQuery
,
source
*
elastic
.
SearchSource
,
conditions
[]
string
,
goods_temp_status
*
int
,
searchValue
*
string
,
keyword
*
string
,
is_sample
*
bool
)
bool
{
func
makeQuery
(
query
*
elastic
.
BoolQuery
,
source
*
elastic
.
SearchSource
,
conditions
[]
string
,
goods_temp_status
*
int
,
searchValue
*
string
,
keyword
*
string
,
is_sample
*
bool
)
bool
{
var
(
err
error
...
...
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