Authored by 郝肖肖

'news详情页分词'

... ... @@ -7,6 +7,7 @@ const NewsAPi = require('./news-api');
const utils = require('./utils');
const moment = require('moment');
const searchHandler = require('../../product/models/search-handler');
const redis = global.yoho.redis;
const BOYS = 'boys';
const GIRLS = 'girls';
... ... @@ -179,6 +180,19 @@ module.exports = class extends global.yoho.BaseModel {
return {header: header, content: utils.filterAhtml(content)};
}
// 潮流详情
getContentDetail(newsAPi, params) {
return redis.all([
['get', `global:yoho:news:detail:${params.id}-${params.cid}`]
]).then(redisData => {
redisData = JSON.parse(redisData[0] || '{}');
if (!redisData.data) {
return newsAPi.getContentDetail(params);
}
return redisData;
});
}
detail(channel, param) {
let params = {
id: param.id,
... ... @@ -196,7 +210,7 @@ module.exports = class extends global.yoho.BaseModel {
content_code: ADS_CODE[channel] || ADS_CODE.boys,
isAdDegrade: _.get(this.ctx, 'req.app.locals.pc.guang.removeAd', false)
}),
newsAPi.getContentDetail(params)
this.getContentDetail(newsAPi, params)
];
return Promise.all(apiMethod).then(result => {
... ...
... ... @@ -34,7 +34,7 @@ const util = {
let $ = cheerio.load(html, {decodeEntities: false});
$('a').attr('href', 'javascript:void(0);').css({cursor: 'text'});// eslint-disable-line
$('a:not(.a-anchor)').attr('href', 'javascript:void(0);').css({cursor: 'text'});// eslint-disable-line
$('script,link').remove();
return $.html();
}
... ...