Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
郭成尧
8 years ago
Commit
8c39ce7128c1a4ed1832b636c6c615895eb4bdd6
2 parents
72779d20
ed40f03f
Merge branch 'feature/wantSearch' into 'release/5.3.1'
搜索接口调整 See merge request
!63
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
36 deletions
apps/product/controllers/search.js
apps/product/models/search.js
apps/product/controllers/search.js
View file @
8c39ce7
...
...
@@ -155,8 +155,8 @@ const index = (req, res, next) => {
search
:
{
defaultTerms
:
(
result
&&
result
.
hotTerms
&&
result
.
hotTerms
.
defaultTerms
&&
result
.
hotTerms
.
defaultTerms
.
length
!==
0
)
?
result
.
hotTerms
.
defaultTerms
[
0
].
content
:
''
,
url
:
helpers
.
urlFormat
(
''
,
null
,
'search'
),
hotTerms
:
result
.
hotTerms
.
hotTerms
,
wantTerms
:
result
.
wantTerms
.
guessTerms
hotTerms
:
result
.
hotTerms
,
wantTerms
:
result
.
guessTerms
}
});
...
...
apps/product/models/search.js
View file @
8c39ce7
...
...
@@ -259,34 +259,16 @@ const getAllBrandNames = () => {
};
/**
* 获取猜你想找
**/
const
getWantSearch
=
(
uid
)
=>
{
* 搜索主页
*/
const
getSearchIndex
=
(
uid
)
=>
{
return
api
.
get
(
''
,
{
method
:
'app.search.get
Some
Terms'
,
method
:
'app.search.getTerms'
,
uid
:
uid
},
{
cache
:
true
}).
then
((
result
)
=>
{
if
(
result
&&
result
.
code
===
200
)
{
return
result
.
data
;
}
else
{
logger
.
error
(
'Hot Search return code is not 200'
);
return
{};
}
});
};
/**
* 获取热门搜索
**/
const
getHotSearch
=
()
=>
{
return
api
.
get
(
''
,
{
method
:
'app.search.getTerms'
},
{
cache
:
true
}).
then
((
result
)
=>
{
if
(
result
&&
result
.
code
===
200
)
{
if
(
result
.
data
.
hotTerms
&&
result
.
data
.
hotTerms
.
length
>
10
)
{
result
.
data
.
hotTerms
=
result
.
data
.
hotTerms
.
slice
(
0
,
10
);
}
...
...
@@ -299,18 +281,6 @@ const getHotSearch = () => {
};
/**
* 搜索主页
*/
const
getSearchIndex
=
(
uid
)
=>
{
return
Promise
.
all
([
getHotSearch
(),
getWantSearch
(
uid
)]).
then
((
result
)
=>
{
return
{
hotTerms
:
result
[
0
],
wantTerms
:
result
[
1
]
};
});
};
/**
* 获取联想词
* @param params
* @returns {*|Promise.<TResult>}
...
...
Please
register
or
login
to post a comment