about.js
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* 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;
})
};
});
}
};