site-map-service.js
1.95 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* map
* @author: xiaoxiao<xiaoxiao.hao@yoho.cn>
* @date: 2017/10/24
*/
'use strict';
const _ = require('lodash');
const path = require('path');
const readFileAsync = Promise.promisify(require('fs').readFile);
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
guangList() {
let filePath = path.resolve(__dirname, './guang-sitemap-ids.txt');
// 异步读取
return readFileAsync(filePath, 'utf-8').then(data => {
return data.toString().split(/\r?\n/ig);
}).catch(err => {
console.log(err);
return [];
});
}
newsList(page, lres) {
return this.get({
url: 'yohonow/api/page/getPolymerizationList',
data: {
type: 'wechat',
limit: 100,
id: 'yohobuy4008899646,yohogroup,YOHO_GIRL,mars-app',
page: page
},
param: {
cache: true
},
api: global.yoho.YohoNowApi
}).then(rdata => {
let artList = _.get(rdata, 'data.content', []);
if (artList.length <= 0) {
return lres;
}
lres = lres.concat(_.map(artList, (art) => {
return `${art.id}_${art.cid}_${art.app}`;
}));
rdata = [];
artList = [];
return this.newsList(++page, lres);
});
}
guangArticles() {
return this.get({
url: '/guang/api/v2/article/getLastArticleList',
data: {
limit: 1000
},
param: {
cache: 86400
},
api: global.yoho.ServiceAPI
});
}
itemList() {
return this.get({
data: {
method: 'web.product.bdPromotion'
},
param: {
cache: 86400
}
});
}
};