...
|
...
|
@@ -10,27 +10,47 @@ const Promise = require('bluebird'); |
|
|
/**
|
|
|
* 资讯详情
|
|
|
*/
|
|
|
const model = {
|
|
|
const model = class extends global.yoho.BaseModel{
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
}
|
|
|
|
|
|
index(params) {
|
|
|
const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/';
|
|
|
|
|
|
return serviceAPI.all([
|
|
|
serviceAPI.get(URI_PACKAGE_ARTICLE + 'getArticle', params),
|
|
|
serviceAPI.get(URI_PACKAGE_ARTICLE + 'getArticleContent', params),
|
|
|
serviceAPI.get(URI_PACKAGE_ARTICLE + 'getBrand', params),
|
|
|
return Promise.all([
|
|
|
this.get({
|
|
|
api: serviceAPI,
|
|
|
url: URI_PACKAGE_ARTICLE + 'getArticle',
|
|
|
data: params
|
|
|
}),
|
|
|
this.get({
|
|
|
api: serviceAPI,
|
|
|
url: URI_PACKAGE_ARTICLE + 'getArticleContent',
|
|
|
data: params
|
|
|
}),
|
|
|
this.get({
|
|
|
api: serviceAPI,
|
|
|
url: URI_PACKAGE_ARTICLE + 'getBrand',
|
|
|
data: params
|
|
|
})
|
|
|
]).then(res => {
|
|
|
const article = res[0];
|
|
|
|
|
|
return serviceAPI.get(URI_PACKAGE_ARTICLE + 'getOtherArticle', Object.assign({
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: URI_PACKAGE_ARTICLE + 'getOtherArticle',
|
|
|
data: Object.assign({
|
|
|
tags: article.data ? article.data.tag : {},
|
|
|
offset: 0,
|
|
|
limit: 3
|
|
|
}, params)).then(other => {
|
|
|
}, params)
|
|
|
}).then(other => {
|
|
|
res.push(other);
|
|
|
return res;
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 点赞
|
...
|
...
|
@@ -40,22 +60,36 @@ const model = { |
|
|
* @returns {*}
|
|
|
*/
|
|
|
like(params, flag) {
|
|
|
let that = this;
|
|
|
|
|
|
return Promise.coroutine(function*() {
|
|
|
let ret = null;
|
|
|
|
|
|
if (flag) {
|
|
|
ret = yield serviceAPI.get('guang/api/v2/praise/setPraise', params);
|
|
|
ret = yield that.get({
|
|
|
api: serviceAPI,
|
|
|
url: 'guang/api/v2/praise/setPraise',
|
|
|
data: params
|
|
|
});
|
|
|
} else {
|
|
|
ret = yield serviceAPI.get('guang/api/v2/praise/cancel', params);
|
|
|
ret = yield that.get({
|
|
|
api: serviceAPI,
|
|
|
url: 'guang/api/v2/praise/cancel',
|
|
|
data: params
|
|
|
});
|
|
|
}
|
|
|
|
|
|
const misc = yield serviceAPI.get('guang/api/v2/article/getArticleBaseInfo', Object.assign({
|
|
|
const misc = yield that.get({
|
|
|
api: serviceAPI,
|
|
|
url: 'guang/api/v2/article/getArticleBaseInfo',
|
|
|
data: Object.assign({
|
|
|
id: params.article_id
|
|
|
}, params));
|
|
|
}, params)
|
|
|
});
|
|
|
|
|
|
return [ret, misc];
|
|
|
})();
|
|
|
},
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 收藏
|
...
|
...
|
@@ -65,22 +99,36 @@ const model = { |
|
|
* @returns {*}
|
|
|
*/
|
|
|
favorite(params, flag) {
|
|
|
let that = this;
|
|
|
|
|
|
return Promise.coroutine(function*() {
|
|
|
let ret = null;
|
|
|
|
|
|
if (flag) {
|
|
|
ret = yield serviceAPI.get('guang/api/v1/favorite/setFavorite', params);
|
|
|
ret = yield that.get({
|
|
|
api: serviceAPI,
|
|
|
url: 'guang/api/v1/favorite/setFavorite',
|
|
|
data: params
|
|
|
});
|
|
|
} else {
|
|
|
ret = yield serviceAPI.get('guang/api/v1/favorite/cancelFavorite', params);
|
|
|
ret = yield that.get({
|
|
|
api: serviceAPI,
|
|
|
url: 'guang/api/v1/favorite/cancelFavorite',
|
|
|
data: params
|
|
|
});
|
|
|
}
|
|
|
|
|
|
const misc = yield serviceAPI.get('guang/api/v2/article/getArticleBaseInfo', Object.assign({
|
|
|
const misc = yield that.get({
|
|
|
api: serviceAPI,
|
|
|
url: 'guang/api/v2/article/getArticleBaseInfo',
|
|
|
data: Object.assign({
|
|
|
id: params.article_id
|
|
|
}, params));
|
|
|
}, params)
|
|
|
});
|
|
|
|
|
|
return [ret, misc];
|
|
|
})();
|
|
|
},
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 其它信息
|
...
|
...
|
@@ -88,9 +136,13 @@ const model = { |
|
|
* @param params
|
|
|
*/
|
|
|
misc(params) {
|
|
|
return serviceAPI.get('guang/api/v2/article/getArticleBaseInfo', Object.assign({
|
|
|
return this.get({
|
|
|
api: serviceAPI,
|
|
|
url: 'guang/api/v2/article/getArticleBaseInfo',
|
|
|
data: Object.assign({
|
|
|
id: params.article_id
|
|
|
}, params));
|
|
|
}, params)
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
|