Authored by yyq

Merge branch 'feature/hotList' into release/0606

... ... @@ -8,7 +8,7 @@
const seoModel = require('../models/seo-service'); // seo 页 model
const hot = (req, res, next) => {
return req.ctx(seoModel).getHotKeywordDate(req.params.id, req.query, req.yoho.channel).then(result => {
return req.ctx(seoModel).getHotKeywordData(req.params.id, req.query, req.yoho.channel).then(result => {
if (!result) {
return next();
}
... ...
... ... @@ -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);
});
}
getHotKeywordDate(id, params, channel) {
getHotKeywordData(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`);
... ...