Authored by yyq

link

... ... @@ -72,7 +72,7 @@ const link = (req, res, next) => {
req.ctx(aboutModel).link(),
]).then(result => {
responseData.headerData = _.get(result, '[0].headerData');
console.log(result)
console.log(result);
res.render('link', Object.assign(_.get(result, '[1]', {}), responseData));
}).catch(next);
};
... ...
/**
* about model
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2017/11/20
*/
const redis = global.yoho.redis;
const _ = require('lodash');
const logger = global.yoho.logger;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
link() {
return redis.all([
['get', 'friend:text:links'],
['get', 'friend:img:links']
]).then(redisData => {
let textLinks = [],
imgLinks = [];
try {
textLinks = JSON.parse(redisData[0] || '[]');
} catch (e) {
logger.error(`friend text links parse error : ${JSON.stringify(e)}`);
}
try {
imgLinks = JSON.parse(redisData[1] || '[]');
} catch (e) {
logger.error(`friend img links parse error : ${JSON.stringify(e)}`);
}
return {
textLinks: _.sortBy(textLinks, o => {return -o.sort}),
imgLinks: _.sortBy(imgLinks, o => {return -o.sort})
};
});
}
};
... ...