...
|
...
|
@@ -11,12 +11,17 @@ const helpers = global.yoho.helpers; |
|
|
const guangProcess = require(`${global.utils}/guang-process`);
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
/**
|
|
|
class IndexModel extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* [获取作者信息]
|
|
|
* @param {[int]} id [作者id]
|
|
|
* @return {[object]}
|
|
|
*/
|
|
|
const getAuthor = (id) => {
|
|
|
getAuthor(id) {
|
|
|
return serviceAPI.get('guang/service/v1/author/getAuthor', {
|
|
|
author_id: id
|
|
|
}, {
|
...
|
...
|
@@ -29,21 +34,9 @@ const getAuthor = (id) => { |
|
|
return {};
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 逛分类
|
|
|
*/
|
|
|
const _category = () => {
|
|
|
return serviceAPI.get('/guang/api/v1/category/get', {
|
|
|
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* [逛内容列表]
|
|
|
* @param {[string]} gender ["1,3"表示男, "2,3"表示女, "1,2,3"表示所有]
|
|
|
* @param {[int]} sortId [分类ID]
|
...
|
...
|
@@ -56,7 +49,7 @@ const _category = () => { |
|
|
* @param {Boolean} useCache [是否使用缓存]
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, useCache) => {
|
|
|
getArticleList(gender, sortId, uid, udid, page, tag, authorId, limit, useCache) {
|
|
|
let param = {
|
|
|
page: page || 1,
|
|
|
uid: uid || 0,
|
...
|
...
|
@@ -79,9 +72,9 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u |
|
|
}
|
|
|
});
|
|
|
|
|
|
};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* [获取切换逛类别或者分页时的文章数据]
|
|
|
* @param {[string]} gender ["1,3"表示男, "2,3"表示女]
|
|
|
* @param {[int]} sortId [分类ID]
|
...
|
...
|
@@ -95,8 +88,8 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u |
|
|
* @param {Boolean} isTab [是否为tab切换操作]
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
const getPageData = (gender, sortId, uid, udid, page, tag, authorId, isApp, showAuthor, isTab) => {
|
|
|
return getArticleList(gender, sortId, uid, udid, page, tag, authorId).then(article => {
|
|
|
getPageData(gender, sortId, uid, udid, page, tag, authorId, isApp, showAuthor, isTab) {
|
|
|
return this.getArticleList(gender, sortId, uid, udid, page, tag, authorId).then(article => {
|
|
|
let result = {};
|
|
|
|
|
|
if (!_.get(article, 'data.list.artList', false)) {
|
...
|
...
|
@@ -124,39 +117,13 @@ const getPageData = (gender, sortId, uid, udid, page, tag, authorId, isApp, show |
|
|
|
|
|
return result;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 逛内容列表
|
|
|
*/
|
|
|
const _article = (param) => {
|
|
|
return serviceAPI.get('/guang/api/v2/article/getList', {
|
|
|
gender: param.gender,
|
|
|
page: param.page || 1,
|
|
|
uid: param.uid,
|
|
|
udid: param.udid,
|
|
|
sort_id: param.type || 0,
|
|
|
tag: param.tag ? param.tag : null,
|
|
|
limit: 4
|
|
|
|
|
|
// author_id: param.authorId ? param.authorId : null,
|
|
|
// limit: param.limit ? param.limit : null
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
|
|
|
return result;
|
|
|
|
|
|
});
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 逛
|
|
|
* @param params
|
|
|
*/
|
|
|
const getArticle = (param) => {
|
|
|
getArticle(param) {
|
|
|
|
|
|
let page = param.page ? param.page : 1;
|
|
|
|
...
|
...
|
@@ -165,8 +132,8 @@ const getArticle = (param) => { |
|
|
});
|
|
|
|
|
|
return api.all([
|
|
|
_category(),
|
|
|
_article(param)
|
|
|
this._category(),
|
|
|
this._article(param)
|
|
|
]).then(result => {
|
|
|
|
|
|
let type = param.type;
|
...
|
...
|
@@ -255,9 +222,9 @@ const getArticle = (param) => { |
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
}
|
|
|
|
|
|
const getTagEditor = (param) => {
|
|
|
getTagEditor(param) {
|
|
|
|
|
|
let page = param.page ? param.page : 1;
|
|
|
|
...
|
...
|
@@ -266,7 +233,7 @@ const getTagEditor = (param) => { |
|
|
});
|
|
|
|
|
|
return api.all([
|
|
|
_article(param)
|
|
|
this._article(param)
|
|
|
]).then(result => {
|
|
|
|
|
|
let resu = {
|
...
|
...
|
@@ -302,9 +269,9 @@ const getTagEditor = (param) => { |
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取制指定文章的动态信息
|
|
|
* @param ids
|
|
|
* @param udid
|
...
|
...
|
@@ -312,7 +279,7 @@ const getTagEditor = (param) => { |
|
|
* @returns {Promise.<T>|*}
|
|
|
*/
|
|
|
|
|
|
const getDynamicDataByIds = (ids, udid, other) => {
|
|
|
getDynamicDataByIds(ids, udid, other) {
|
|
|
let params = {
|
|
|
articleIds: ids,
|
|
|
udid: udid
|
...
|
...
|
@@ -337,28 +304,58 @@ const getDynamicDataByIds = (ids, udid, other) => { |
|
|
}
|
|
|
|
|
|
return serviceAPI.get('guang/api/v6/article/getSimpleArticleList', params);
|
|
|
};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 获取制指定文章的动态信息
|
|
|
* @param ids
|
|
|
* @returns {Promise.<T>|*}
|
|
|
*/
|
|
|
|
|
|
const getDynamicDataById = (id, uid, udid) => {
|
|
|
getDynamicDataById(id, uid, udid) {
|
|
|
return serviceAPI.get('guang/api/v6/article/getArticlePraiseAndFavor', {
|
|
|
id: id,
|
|
|
uid: uid,
|
|
|
udid: udid
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getAuthor,
|
|
|
getArticleList,
|
|
|
getPageData,
|
|
|
getArticle,
|
|
|
getTagEditor,
|
|
|
getDynamicDataByIds,
|
|
|
getDynamicDataById
|
|
|
}; |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 逛分类
|
|
|
*/
|
|
|
_category() {
|
|
|
return serviceAPI.get('/guang/api/v1/category/get', {
|
|
|
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 逛内容列表
|
|
|
*/
|
|
|
_article(param) {
|
|
|
return serviceAPI.get('/guang/api/v2/article/getList', {
|
|
|
gender: param.gender,
|
|
|
page: param.page || 1,
|
|
|
uid: param.uid,
|
|
|
udid: param.udid,
|
|
|
sort_id: param.type || 0,
|
|
|
tag: param.tag ? param.tag : null,
|
|
|
limit: 4
|
|
|
|
|
|
// author_id: param.authorId ? param.authorId : null,
|
|
|
// limit: param.limit ? param.limit : null
|
|
|
}, {
|
|
|
cache: true,
|
|
|
code: 200
|
|
|
}).then(result => {
|
|
|
|
|
|
return result;
|
|
|
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = IndexModel; |
...
|
...
|
|