channel与editorial相关接口上下文修改
Showing
13 changed files
with
198 additions
and
87 deletions
@@ -26,7 +26,7 @@ module.exports = { | @@ -26,7 +26,7 @@ module.exports = { | ||
26 | /* 获取品牌列表数据 */ | 26 | /* 获取品牌列表数据 */ |
27 | getBrandList: (req, res, next) => { | 27 | getBrandList: (req, res, next) => { |
28 | 28 | ||
29 | - brandModel.getBrandListData({ | 29 | + req.ctx(brandModel).getBrandListData({ |
30 | channel: req.query.channel | 30 | channel: req.query.channel |
31 | }).then(result => { | 31 | }).then(result => { |
32 | res.json(result); | 32 | res.json(result); |
@@ -44,7 +44,7 @@ module.exports = { | @@ -44,7 +44,7 @@ module.exports = { | ||
44 | 44 | ||
45 | // 全部分类api | 45 | // 全部分类api |
46 | getCateList: (req, res, next) => { | 46 | getCateList: (req, res, next) => { |
47 | - brandModel.getCateListData({ | 47 | + req.ctx(brandModel).getCateListData({ |
48 | app_type: 1 | 48 | app_type: 1 |
49 | }).then(result => { | 49 | }).then(result => { |
50 | res.json(result); | 50 | res.json(result); |
@@ -19,7 +19,7 @@ module.exports = { | @@ -19,7 +19,7 @@ module.exports = { | ||
19 | index(req, res, next) { | 19 | index(req, res, next) { |
20 | let channel = req.path.split('/')[1] || req.yoho.channel; | 20 | let channel = req.path.split('/')[1] || req.yoho.channel; |
21 | 21 | ||
22 | - channelModel.getResourcesData({ | 22 | + req.ctx(channelModel).getResourcesData({ |
23 | contentCode: channelMap[channel] | 23 | contentCode: channelMap[channel] |
24 | }).then(result => { | 24 | }).then(result => { |
25 | const resources = result.slice(0, 3); | 25 | const resources = result.slice(0, 3); |
@@ -41,17 +41,17 @@ module.exports = { | @@ -41,17 +41,17 @@ module.exports = { | ||
41 | }).catch(next); | 41 | }).catch(next); |
42 | }, | 42 | }, |
43 | channel(req, res, next) { | 43 | channel(req, res, next) { |
44 | - channelModel.getChannelData().then(result => { | 44 | + req.ctx(channelModel).getChannelData().then(result => { |
45 | return res.json(result); | 45 | return res.json(result); |
46 | }).catch(next); | 46 | }).catch(next); |
47 | }, | 47 | }, |
48 | resources(req, res, next) { | 48 | resources(req, res, next) { |
49 | - channelModel.getResourcesData(req.query).then(result => { | 49 | + req.ctx(channelModel).getResourcesData(req.query).then(result => { |
50 | return res.json(result); | 50 | return res.json(result); |
51 | }).catch(next); | 51 | }).catch(next); |
52 | }, | 52 | }, |
53 | goods(req, res, next) { | 53 | goods(req, res, next) { |
54 | - channelModel.getGoodsData(req.query).then(result => { | 54 | + req.ctx(channelModel).getGoodsData(req.query).then(result => { |
55 | return res.json(result); | 55 | return res.json(result); |
56 | }).catch(next); | 56 | }).catch(next); |
57 | }, | 57 | }, |
@@ -62,7 +62,7 @@ module.exports = { | @@ -62,7 +62,7 @@ module.exports = { | ||
62 | page: 'sidebar' | 62 | page: 'sidebar' |
63 | }); | 63 | }); |
64 | } | 64 | } |
65 | - channelModel.getSidebarData(req.query).then(result => { | 65 | + req.ctx(channelModel).getSidebarData(req.query).then(result => { |
66 | return res.json(result); | 66 | return res.json(result); |
67 | }).catch(next); | 67 | }).catch(next); |
68 | } | 68 | } |
@@ -5,7 +5,8 @@ | @@ -5,7 +5,8 @@ | ||
5 | * Time: 14:02 | 5 | * Time: 14:02 |
6 | */ | 6 | */ |
7 | 'use strict'; | 7 | 'use strict'; |
8 | -const api = global.yoho.API; | 8 | + |
9 | +// const api = global.yoho.API; | ||
9 | 10 | ||
10 | const yhChannel = { | 11 | const yhChannel = { |
11 | men: { | 12 | men: { |
@@ -19,32 +20,42 @@ const yhChannel = { | @@ -19,32 +20,42 @@ const yhChannel = { | ||
19 | } | 20 | } |
20 | }; | 21 | }; |
21 | 22 | ||
22 | -module.exports = { | 23 | +module.exports = class extends global.yoho.BaseModel{ |
24 | + constructor(ctx) { | ||
25 | + super(ctx); | ||
26 | + } | ||
23 | 27 | ||
24 | /** | 28 | /** |
25 | * 从接口获取品牌列表页数据 | 29 | * 从接口获取品牌列表页数据 |
26 | * @returns {*} | 30 | * @returns {*} |
27 | */ | 31 | */ |
28 | getBrandListOriginData(params) { | 32 | getBrandListOriginData(params) { |
29 | - return api.get('', { | ||
30 | - method: 'app.brand.allBrandList', | ||
31 | - yh_channel: params.channel ? yhChannel[params.channel].channel : '' | ||
32 | - }, { | 33 | + |
34 | + return this.get({ | ||
35 | + data: { | ||
36 | + yh_channel: params.channel ? yhChannel[params.channel].channel : '', | ||
37 | + method: 'app.brand.allBrandList' | ||
38 | + }, | ||
39 | + param: { | ||
33 | code: 200, | 40 | code: 200, |
34 | cache: true | 41 | cache: true |
42 | + } | ||
35 | }); | 43 | }); |
36 | - }, | 44 | + } |
37 | 45 | ||
38 | /** | 46 | /** |
39 | * 从接口获取全部分类数据 | 47 | * 从接口获取全部分类数据 |
40 | * @returns {*} | 48 | * @returns {*} |
41 | */ | 49 | */ |
42 | getCateListData(params) { | 50 | getCateListData(params) { |
43 | - return api.get('', Object.assign(params, { | 51 | + return this.get({ |
52 | + data: Object.assign(params, { | ||
44 | method: 'app.sort.get' | 53 | method: 'app.sort.get' |
45 | - }, { | 54 | + }), |
55 | + param: { | ||
46 | code: 200, | 56 | code: 200, |
47 | cache: true | 57 | cache: true |
48 | - })); | 58 | + } |
59 | + }); | ||
49 | } | 60 | } |
50 | }; | 61 | }; |
@@ -6,15 +6,20 @@ | @@ -6,15 +6,20 @@ | ||
6 | */ | 6 | */ |
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | -const brandApi = require('./brand-api'); | 9 | +const BrandApi = require('./brand-api'); |
10 | const _ = require('lodash'); | 10 | const _ = require('lodash'); |
11 | 11 | ||
12 | -/** | 12 | +module.exports = class extends global.yoho.BaseModel { |
13 | + constructor(ctx) { | ||
14 | + super(ctx); | ||
15 | + } | ||
16 | + | ||
17 | + /** | ||
13 | * 处理品牌一览品牌列表数据 | 18 | * 处理品牌一览品牌列表数据 |
14 | * @param origin | 19 | * @param origin |
15 | * @returns {Array} | 20 | * @returns {Array} |
16 | */ | 21 | */ |
17 | -const handleBrandList = origin => { | 22 | + handleBrandList(origin) { |
18 | let dest = { | 23 | let dest = { |
19 | brandList: [], | 24 | brandList: [], |
20 | indexList: [] | 25 | indexList: [] |
@@ -97,34 +102,40 @@ const handleBrandList = origin => { | @@ -97,34 +102,40 @@ const handleBrandList = origin => { | ||
97 | } | 102 | } |
98 | 103 | ||
99 | return dest; | 104 | return dest; |
100 | -}; | 105 | + } |
101 | 106 | ||
102 | -/** | 107 | + /** |
103 | * 获取品牌列表页数据 | 108 | * 获取品牌列表页数据 |
104 | * @param params | 109 | * @param params |
105 | */ | 110 | */ |
106 | -const getBrandListData = params => { | 111 | + getBrandListData(params) { |
107 | let finalResult = {}; | 112 | let finalResult = {}; |
113 | + let brandData = new BrandApi(this.ctx); | ||
114 | + let that = this; | ||
108 | 115 | ||
109 | - return brandApi.getBrandListOriginData(params).then(result => { | 116 | + return brandData.getBrandListOriginData(params).then(result => { |
110 | if (result && result.data) { | 117 | if (result && result.data) { |
111 | - Object.assign(finalResult, handleBrandList(result.data.all_list)); | 118 | + Object.assign(finalResult, that.handleBrandList(result.data.all_list)); |
112 | } | 119 | } |
113 | 120 | ||
114 | return finalResult; | 121 | return finalResult; |
115 | }); | 122 | }); |
116 | -}; | 123 | + } |
117 | 124 | ||
118 | -/** | 125 | + |
126 | + /** | ||
119 | * 获取全部分类数据 | 127 | * 获取全部分类数据 |
120 | * @param params | 128 | * @param params |
121 | * @returns {*|Promise.<TResult>} | 129 | * @returns {*|Promise.<TResult>} |
122 | */ | 130 | */ |
123 | -const getCateListData = params => { | ||
124 | - return brandApi.getCateListData(params); | 131 | + getCateListData(params) { |
132 | + let brandData = new BrandApi(this.ctx); | ||
133 | + | ||
134 | + return brandData.getCateListData(params); | ||
135 | + } | ||
125 | }; | 136 | }; |
126 | 137 | ||
127 | -module.exports = { | 138 | +/* module.exports = { |
128 | getBrandListData, | 139 | getBrandListData, |
129 | getCateListData | 140 | getCateListData |
130 | -}; | 141 | +}; */ |
1 | 'use strict'; | 1 | 'use strict'; |
2 | + | ||
3 | +// const api = global.yoho.API; | ||
2 | const service = global.yoho.ServiceAPI; | 4 | const service = global.yoho.ServiceAPI; |
3 | -const api = global.yoho.API; | ||
4 | const processResources = require(`${global.utils}/beautify/resources`); | 5 | const processResources = require(`${global.utils}/beautify/resources`); |
5 | const processProductList = require(`${global.utils}/beautify/product`); | 6 | const processProductList = require(`${global.utils}/beautify/product`); |
6 | 7 | ||
7 | -let channel = { | 8 | + |
9 | +let channel = class extends global.yoho.BaseModel { | ||
10 | + constructor(ctx) { | ||
11 | + super(ctx); | ||
12 | + } | ||
13 | + | ||
8 | getResourcesData(params) { | 14 | getResourcesData(params) { |
9 | if (!params.contentCode) { | 15 | if (!params.contentCode) { |
10 | return Promise.resolve([]); | 16 | return Promise.resolve([]); |
11 | } | 17 | } |
12 | - return service.get('operations/api/v5/resource/get', { | 18 | + |
19 | + return this.get({ | ||
20 | + api: service, | ||
21 | + url: 'operations/api/v5/resource/get', | ||
22 | + data: { | ||
13 | content_code: params.contentCode | 23 | content_code: params.contentCode |
14 | - }, { | 24 | + }, |
25 | + param: { | ||
15 | cache: true, | 26 | cache: true, |
16 | code: 200 | 27 | code: 200 |
28 | + } | ||
17 | }).then(result => { | 29 | }).then(result => { |
18 | return result && result.data ? processResources(result.data) : []; | 30 | return result && result.data ? processResources(result.data) : []; |
19 | }); | 31 | }); |
20 | - }, | 32 | + } |
33 | + | ||
21 | getSidebarData() { | 34 | getSidebarData() { |
22 | - return service.get('operations/api/v6/category/getCategory', {}, { | 35 | + return this.get({ |
36 | + api: service, | ||
37 | + url: 'operations/api/v6/category/getCategory', | ||
38 | + data: {}, | ||
39 | + param: { | ||
23 | cache: true, | 40 | cache: true, |
24 | code: 200 | 41 | code: 200 |
42 | + } | ||
25 | }); | 43 | }); |
26 | - }, | 44 | + } |
45 | + | ||
27 | getGoodsData(params) { | 46 | getGoodsData(params) { |
28 | if (!params.productSkn || !params.productSkn.length) { | 47 | if (!params.productSkn || !params.productSkn.length) { |
29 | return Promise.resolve([]); | 48 | return Promise.resolve([]); |
30 | } | 49 | } |
31 | - return api.get('', { | ||
32 | - method: 'h5.product.batch', | ||
33 | - productSkn: params.productSkn | ||
34 | - }, { | 50 | + |
51 | + return this.get({ | ||
52 | + data: { | ||
53 | + productSkn: params.productSkn, | ||
54 | + method: 'h5.product.batch' | ||
55 | + }, | ||
56 | + param: { | ||
35 | cache: true, | 57 | cache: true, |
36 | code: 200 | 58 | code: 200 |
59 | + } | ||
37 | }).then(result => { | 60 | }).then(result => { |
38 | return result && result.data ? processProductList(result.data.product_list) : []; | 61 | return result && result.data ? processProductList(result.data.product_list) : []; |
39 | }); | 62 | }); |
40 | - }, | 63 | + } |
64 | + | ||
41 | getChannelData() { | 65 | getChannelData() { |
42 | - return api.get('', { | 66 | + return this.get({ |
67 | + data: { | ||
43 | method: 'app.blk.getAllChannels' | 68 | method: 'app.blk.getAllChannels' |
44 | - }, { | 69 | + }, |
70 | + param: { | ||
45 | cache: true, | 71 | cache: true, |
46 | code: 200 | 72 | code: 200 |
73 | + } | ||
47 | }); | 74 | }); |
48 | } | 75 | } |
49 | }; | 76 | }; |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | */ | 5 | */ |
6 | 'use strict'; | 6 | 'use strict'; |
7 | 7 | ||
8 | -const model = require('../models/detail'); | 8 | +const DetailModel = require('../models/detail'); |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * 商品详情 | 11 | * 商品详情 |
@@ -29,7 +29,7 @@ const component = { | @@ -29,7 +29,7 @@ const component = { | ||
29 | client_type: 'h5' | 29 | client_type: 'h5' |
30 | }; | 30 | }; |
31 | 31 | ||
32 | - model.index(params).then(result => { | 32 | + req.ctx(DetailModel).index(params).then(result => { |
33 | res.json(result); | 33 | res.json(result); |
34 | }).catch(next); | 34 | }).catch(next); |
35 | }, | 35 | }, |
@@ -49,7 +49,7 @@ const component = { | @@ -49,7 +49,7 @@ const component = { | ||
49 | // uid: req.user.uid || 8050378 | 49 | // uid: req.user.uid || 8050378 |
50 | }; | 50 | }; |
51 | 51 | ||
52 | - model.like(params, req.query.flag === 'true').then(result => { | 52 | + req.ctx(DetailModel).like(params, req.query.flag === 'true').then(result => { |
53 | res.json(result); | 53 | res.json(result); |
54 | }).catch(next); | 54 | }).catch(next); |
55 | }, | 55 | }, |
@@ -75,7 +75,7 @@ const component = { | @@ -75,7 +75,7 @@ const component = { | ||
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | 77 | ||
78 | - model.favorite(params, req.query.flag === 'true').then(result => { | 78 | + req.ctx(DetailModel).favorite(params, req.query.flag === 'true').then(result => { |
79 | res.json(result); | 79 | res.json(result); |
80 | }).catch(next); | 80 | }).catch(next); |
81 | }, | 81 | }, |
@@ -94,7 +94,7 @@ const component = { | @@ -94,7 +94,7 @@ const component = { | ||
94 | udid: req.sessionID | 94 | udid: req.sessionID |
95 | }; | 95 | }; |
96 | 96 | ||
97 | - model.misc(params).then(result => { | 97 | + req.ctx(DetailModel).misc(params).then(result => { |
98 | res.json(result); | 98 | res.json(result); |
99 | }).catch(next); | 99 | }).catch(next); |
100 | } | 100 | } |
@@ -27,7 +27,7 @@ module.exports = { | @@ -27,7 +27,7 @@ module.exports = { | ||
27 | uid: req.user.uid | 27 | uid: req.user.uid |
28 | }; | 28 | }; |
29 | 29 | ||
30 | - listModel.editorialList(params).then(result => { | 30 | + req.ctx(listModel).editorialList(params).then(result => { |
31 | res.json(result); | 31 | res.json(result); |
32 | }).catch(next); | 32 | }).catch(next); |
33 | } | 33 | } |
@@ -10,27 +10,47 @@ const Promise = require('bluebird'); | @@ -10,27 +10,47 @@ const Promise = require('bluebird'); | ||
10 | /** | 10 | /** |
11 | * 资讯详情 | 11 | * 资讯详情 |
12 | */ | 12 | */ |
13 | -const model = { | 13 | +const model = class extends global.yoho.BaseModel{ |
14 | + constructor(ctx) { | ||
15 | + super(ctx); | ||
16 | + } | ||
17 | + | ||
14 | index(params) { | 18 | index(params) { |
15 | const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/'; | 19 | const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/'; |
16 | 20 | ||
17 | - return serviceAPI.all([ | ||
18 | - serviceAPI.get(URI_PACKAGE_ARTICLE + 'getArticle', params), | ||
19 | - serviceAPI.get(URI_PACKAGE_ARTICLE + 'getArticleContent', params), | ||
20 | - serviceAPI.get(URI_PACKAGE_ARTICLE + 'getBrand', params), | 21 | + return Promise.all([ |
22 | + this.get({ | ||
23 | + api: serviceAPI, | ||
24 | + url: URI_PACKAGE_ARTICLE + 'getArticle', | ||
25 | + data: params | ||
26 | + }), | ||
27 | + this.get({ | ||
28 | + api: serviceAPI, | ||
29 | + url: URI_PACKAGE_ARTICLE + 'getArticleContent', | ||
30 | + data: params | ||
31 | + }), | ||
32 | + this.get({ | ||
33 | + api: serviceAPI, | ||
34 | + url: URI_PACKAGE_ARTICLE + 'getBrand', | ||
35 | + data: params | ||
36 | + }) | ||
21 | ]).then(res => { | 37 | ]).then(res => { |
22 | const article = res[0]; | 38 | const article = res[0]; |
23 | 39 | ||
24 | - return serviceAPI.get(URI_PACKAGE_ARTICLE + 'getOtherArticle', Object.assign({ | 40 | + return this.get({ |
41 | + api: serviceAPI, | ||
42 | + url: URI_PACKAGE_ARTICLE + 'getOtherArticle', | ||
43 | + data: Object.assign({ | ||
25 | tags: article.data ? article.data.tag : {}, | 44 | tags: article.data ? article.data.tag : {}, |
26 | offset: 0, | 45 | offset: 0, |
27 | limit: 3 | 46 | limit: 3 |
28 | - }, params)).then(other => { | 47 | + }, params) |
48 | + }).then(other => { | ||
29 | res.push(other); | 49 | res.push(other); |
30 | return res; | 50 | return res; |
31 | }); | 51 | }); |
32 | }); | 52 | }); |
33 | - }, | 53 | + } |
34 | 54 | ||
35 | /** | 55 | /** |
36 | * 点赞 | 56 | * 点赞 |
@@ -40,22 +60,36 @@ const model = { | @@ -40,22 +60,36 @@ const model = { | ||
40 | * @returns {*} | 60 | * @returns {*} |
41 | */ | 61 | */ |
42 | like(params, flag) { | 62 | like(params, flag) { |
63 | + let that = this; | ||
64 | + | ||
43 | return Promise.coroutine(function*() { | 65 | return Promise.coroutine(function*() { |
44 | let ret = null; | 66 | let ret = null; |
45 | 67 | ||
46 | if (flag) { | 68 | if (flag) { |
47 | - ret = yield serviceAPI.get('guang/api/v2/praise/setPraise', params); | 69 | + ret = yield that.get({ |
70 | + api: serviceAPI, | ||
71 | + url: 'guang/api/v2/praise/setPraise', | ||
72 | + data: params | ||
73 | + }); | ||
48 | } else { | 74 | } else { |
49 | - ret = yield serviceAPI.get('guang/api/v2/praise/cancel', params); | 75 | + ret = yield that.get({ |
76 | + api: serviceAPI, | ||
77 | + url: 'guang/api/v2/praise/cancel', | ||
78 | + data: params | ||
79 | + }); | ||
50 | } | 80 | } |
51 | 81 | ||
52 | - const misc = yield serviceAPI.get('guang/api/v2/article/getArticleBaseInfo', Object.assign({ | 82 | + const misc = yield that.get({ |
83 | + api: serviceAPI, | ||
84 | + url: 'guang/api/v2/article/getArticleBaseInfo', | ||
85 | + data: Object.assign({ | ||
53 | id: params.article_id | 86 | id: params.article_id |
54 | - }, params)); | 87 | + }, params) |
88 | + }); | ||
55 | 89 | ||
56 | return [ret, misc]; | 90 | return [ret, misc]; |
57 | })(); | 91 | })(); |
58 | - }, | 92 | + } |
59 | 93 | ||
60 | /** | 94 | /** |
61 | * 收藏 | 95 | * 收藏 |
@@ -65,22 +99,36 @@ const model = { | @@ -65,22 +99,36 @@ const model = { | ||
65 | * @returns {*} | 99 | * @returns {*} |
66 | */ | 100 | */ |
67 | favorite(params, flag) { | 101 | favorite(params, flag) { |
102 | + let that = this; | ||
103 | + | ||
68 | return Promise.coroutine(function*() { | 104 | return Promise.coroutine(function*() { |
69 | let ret = null; | 105 | let ret = null; |
70 | 106 | ||
71 | if (flag) { | 107 | if (flag) { |
72 | - ret = yield serviceAPI.get('guang/api/v1/favorite/setFavorite', params); | 108 | + ret = yield that.get({ |
109 | + api: serviceAPI, | ||
110 | + url: 'guang/api/v1/favorite/setFavorite', | ||
111 | + data: params | ||
112 | + }); | ||
73 | } else { | 113 | } else { |
74 | - ret = yield serviceAPI.get('guang/api/v1/favorite/cancelFavorite', params); | 114 | + ret = yield that.get({ |
115 | + api: serviceAPI, | ||
116 | + url: 'guang/api/v1/favorite/cancelFavorite', | ||
117 | + data: params | ||
118 | + }); | ||
75 | } | 119 | } |
76 | 120 | ||
77 | - const misc = yield serviceAPI.get('guang/api/v2/article/getArticleBaseInfo', Object.assign({ | 121 | + const misc = yield that.get({ |
122 | + api: serviceAPI, | ||
123 | + url: 'guang/api/v2/article/getArticleBaseInfo', | ||
124 | + data: Object.assign({ | ||
78 | id: params.article_id | 125 | id: params.article_id |
79 | - }, params)); | 126 | + }, params) |
127 | + }); | ||
80 | 128 | ||
81 | return [ret, misc]; | 129 | return [ret, misc]; |
82 | })(); | 130 | })(); |
83 | - }, | 131 | + } |
84 | 132 | ||
85 | /** | 133 | /** |
86 | * 其它信息 | 134 | * 其它信息 |
@@ -88,9 +136,13 @@ const model = { | @@ -88,9 +136,13 @@ const model = { | ||
88 | * @param params | 136 | * @param params |
89 | */ | 137 | */ |
90 | misc(params) { | 138 | misc(params) { |
91 | - return serviceAPI.get('guang/api/v2/article/getArticleBaseInfo', Object.assign({ | 139 | + return this.get({ |
140 | + api: serviceAPI, | ||
141 | + url: 'guang/api/v2/article/getArticleBaseInfo', | ||
142 | + data: Object.assign({ | ||
92 | id: params.article_id | 143 | id: params.article_id |
93 | - }, params)); | 144 | + }, params) |
145 | + }); | ||
94 | } | 146 | } |
95 | }; | 147 | }; |
96 | 148 |
@@ -20,16 +20,27 @@ const yhChannel = { | @@ -20,16 +20,27 @@ const yhChannel = { | ||
20 | } | 20 | } |
21 | }; | 21 | }; |
22 | 22 | ||
23 | -module.exports = { | 23 | +module.exports = class extends global.yoho.BaseModel{ |
24 | + constructor(ctx) { | ||
25 | + super(ctx); | ||
26 | + } | ||
24 | 27 | ||
25 | /* 资讯列表页数据获取 */ | 28 | /* 资讯列表页数据获取 */ |
26 | getEditorialListData(params) { | 29 | getEditorialListData(params) { |
27 | - return serviceAPI.get('guang/api/v2/article/getList', { | 30 | + return this.get({ |
31 | + api: serviceAPI, | ||
32 | + url: 'guang/api/v2/article/getList', | ||
33 | + data: { | ||
28 | sort_id: '', | 34 | sort_id: '', |
29 | gender: yhChannel[params.channel || 'all'].channel, | 35 | gender: yhChannel[params.channel || 'all'].channel, |
30 | uid: params.uid || '0', | 36 | uid: params.uid || '0', |
31 | page: params.page, | 37 | page: params.page, |
32 | limit: '10' | 38 | limit: '10' |
33 | - }, {code: 200, cache: true}); | 39 | + }, |
40 | + param: { | ||
41 | + code: 200, | ||
42 | + cache: true | ||
43 | + } | ||
44 | + }); | ||
34 | } | 45 | } |
35 | }; | 46 | }; |
@@ -6,17 +6,24 @@ | @@ -6,17 +6,24 @@ | ||
6 | */ | 6 | */ |
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | -const editorialListApi = require('./list-api'); | 9 | +const EditorialListApi = require('./list-api'); |
10 | 10 | ||
11 | /** | 11 | /** |
12 | * 资讯列表数据 | 12 | * 资讯列表数据 |
13 | * @param params | 13 | * @param params |
14 | * @returns {*|Promise.<TResult>} | 14 | * @returns {*|Promise.<TResult>} |
15 | */ | 15 | */ |
16 | -const editorialList = params => { | 16 | + |
17 | +module.exports = class extends global.yoho.BaseModel { | ||
18 | + constructor(ctx) { | ||
19 | + super(ctx); | ||
20 | + } | ||
21 | + | ||
22 | + editorialList(params) { | ||
17 | let finalResult = {}; | 23 | let finalResult = {}; |
24 | + let editorialListData = new EditorialListApi(this.ctx); | ||
18 | 25 | ||
19 | - return editorialListApi.getEditorialListData(params).then(result => { | 26 | + return editorialListData.getEditorialListData(params).then(result => { |
20 | if (result && result.data) { | 27 | if (result && result.data) { |
21 | Object.assign(finalResult, { | 28 | Object.assign(finalResult, { |
22 | data: { | 29 | data: { |
@@ -29,8 +36,5 @@ const editorialList = params => { | @@ -29,8 +36,5 @@ const editorialList = params => { | ||
29 | 36 | ||
30 | return finalResult; | 37 | return finalResult; |
31 | }); | 38 | }); |
32 | -}; | ||
33 | - | ||
34 | -module.exports = { | ||
35 | - editorialList | 39 | + } |
36 | }; | 40 | }; |
@@ -12,7 +12,7 @@ const config = require('./config/common'); | @@ -12,7 +12,7 @@ const config = require('./config/common'); | ||
12 | // require('oneapm'); | 12 | // require('oneapm'); |
13 | // } | 13 | // } |
14 | 14 | ||
15 | -const heapdump = require('heapdump'); | 15 | +// const heapdump = require('heapdump'); |
16 | const express = require('express'); | 16 | const express = require('express'); |
17 | const path = require('path'); | 17 | const path = require('path'); |
18 | const bodyParser = require('body-parser'); | 18 | const bodyParser = require('body-parser'); |
@@ -37,7 +37,6 @@ | @@ -37,7 +37,6 @@ | ||
37 | "express-session": "^1.14.1", | 37 | "express-session": "^1.14.1", |
38 | "global": "^4.3.2", | 38 | "global": "^4.3.2", |
39 | "happypack": "^3.1.0", | 39 | "happypack": "^3.1.0", |
40 | - "heapdump": "^0.3.9", | ||
41 | "influxdb-winston": "^1.0.1", | 40 | "influxdb-winston": "^1.0.1", |
42 | "lodash": "^4.15.0", | 41 | "lodash": "^4.15.0", |
43 | "lodash-cli": "^4.17.4", | 42 | "lodash-cli": "^4.17.4", |
@@ -4022,10 +4022,6 @@ header-case@^1.0.0: | @@ -4022,10 +4022,6 @@ header-case@^1.0.0: | ||
4022 | no-case "^2.2.0" | 4022 | no-case "^2.2.0" |
4023 | upper-case "^1.1.3" | 4023 | upper-case "^1.1.3" |
4024 | 4024 | ||
4025 | -heapdump@^0.3.9: | ||
4026 | - version "0.3.9" | ||
4027 | - resolved "http://npm.yohops.com/heapdump/-/heapdump-0.3.9.tgz#03c74eb0df5d67be0982e83429ba9c9d2b3b7f78" | ||
4028 | - | ||
4029 | hmac-drbg@^1.0.0: | 4025 | hmac-drbg@^1.0.0: |
4030 | version "1.0.1" | 4026 | version "1.0.1" |
4031 | resolved "http://npm.yohops.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" | 4027 | resolved "http://npm.yohops.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" |
-
Please register or login to post a comment