Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
yyq
7 years ago
Commit
b5a109801b0998ef7a51555787995f658e2490b5
2 parents
bede6538
5b30f342
Merge branch 'feature/hotList' into release/0606
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
apps/product/controllers/seo.js
apps/product/models/seo-service.js
apps/product/controllers/seo.js
View file @
b5a1098
...
...
@@ -8,7 +8,7 @@
const
seoModel
=
require
(
'../models/seo-service'
);
// seo 页 model
const
hot
=
(
req
,
res
,
next
)
=>
{
return
req
.
ctx
(
seoModel
).
getHotKeywordDat
e
(
req
.
params
.
id
,
req
.
query
,
req
.
yoho
.
channel
).
then
(
result
=>
{
return
req
.
ctx
(
seoModel
).
getHotKeywordDat
a
(
req
.
params
.
id
,
req
.
query
,
req
.
yoho
.
channel
).
then
(
result
=>
{
if
(
!
result
)
{
return
next
();
}
...
...
apps/product/models/seo-service.js
View file @
b5a1098
...
...
@@ -94,7 +94,7 @@ module.exports = class extends global.yoho.BaseModel {
this
.
searchApi
=
new
SearchApi
(
ctx
);
}
getSearchProduct
(
params
,
channel
)
{
getSearchProduct
(
params
,
channel
,
sort
)
{
let
searchParams
=
searchHandler
.
getSearchParams
(
params
);
switch
(
channel
)
{
...
...
@@ -121,16 +121,30 @@ module.exports = class extends global.yoho.BaseModel {
return
Promise
.
all
([
headerModelCtx
.
requestHeaderData
(
channel
,
true
),
this
.
searchApi
.
getSeoProductList
(
searchParams
,
'fuzzySearch'
),
this
.
searchApi
.
getSeoProductList
(
Object
.
assign
(
searchParams
,
{
this
.
searchApi
.
getSeoProductList
(
Object
.
assign
(
{},
searchParams
,
{
order
:
's_n_desc'
,
limit
:
5
}),
'fuzzySearch'
),
]).
then
(
result
=>
{
if
(
!
sort
||
_
.
get
(
result
[
1
],
'data.total'
)
>
0
)
{
return
result
;
}
delete
searchParams
.
query
;
searchParams
.
sort
=
sort
;
return
this
.
searchApi
.
getSeoProductList
(
searchParams
,
'fuzzySearch'
).
then
(
subRes
=>
{
result
[
1
]
=
subRes
;
return
result
;
});
}).
then
(
result
=>
{
return
_setHotKeywordData
(
result
,
params
,
channel
);
});
}
getHotKeywordDat
e
(
id
,
params
,
channel
)
{
getHotKeywordDat
a
(
id
,
params
,
channel
)
{
return
redis
.
all
([
[
'get'
,
`
global
:
yoho
:
seo
:
hot
:
keywords
:
id
:
$
{
id
}
`
]
]).
then
(
redisData
=>
{
...
...
@@ -149,7 +163,7 @@ module.exports = class extends global.yoho.BaseModel {
params
.
query
=
keyword
.
name
;
return
this
.
getSearchProduct
(
params
,
channel
).
then
(
result
=>
{
return
this
.
getSearchProduct
(
params
,
channel
,
keyword
.
sort_id
).
then
(
result
=>
{
const
keyNum
=
10
;
let
hotKeys
=
(
keyword
.
data
||
[]).
map
(
val
=>
{
val
.
href
=
helpers
.
urlFormat
(
`
/
hot
/
$
{
val
.
id
}.
html
`
);
...
...
Please
register
or
login
to post a comment