...
|
...
|
@@ -87,6 +87,82 @@ const article = { |
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 文章列表无图
|
|
|
* @param req
|
|
|
* @param res
|
|
|
* @param next
|
|
|
*/
|
|
|
listNoImg(req, res, next) {
|
|
|
const query = req.query;
|
|
|
const actId = query.actId;
|
|
|
const pageNo = query.pageNo || 1;
|
|
|
const pageSize = query.pageSize || 10;
|
|
|
const orderBy = query.orderBy || 'createTime';
|
|
|
const order = ((query.order || 'desc') + '').toLowerCase();
|
|
|
const orderByFields = ['createTime', 'goodCount', 'id'];
|
|
|
|
|
|
console.log('query', query);
|
|
|
if (!actId) {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
message: INVALID_PARAMS
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (order !== 'asc' && order !== 'desc') {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
message: INVALID_PARAMS
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (orderByFields.indexOf(orderBy) === -1) {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
message: INVALID_PARAMS
|
|
|
});
|
|
|
}
|
|
|
|
|
|
req.ctx(ArticleModel).articleListWithOutImg({
|
|
|
actId,
|
|
|
order,
|
|
|
orderBy,
|
|
|
pageNo,
|
|
|
pageSize
|
|
|
})
|
|
|
.then(result => {
|
|
|
console.log('result', result);
|
|
|
let list = [];
|
|
|
|
|
|
_.each(result, item => {
|
|
|
let data = {};
|
|
|
|
|
|
_.each(item, (val, key) => {
|
|
|
data[camelcase(key)] = val;
|
|
|
});
|
|
|
list.push(data);
|
|
|
});
|
|
|
return list;
|
|
|
})
|
|
|
.then(list => {
|
|
|
req.ctx(ArticleModel).allArticlesNum(actId)
|
|
|
.then(totalCount => {
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
data: list,
|
|
|
pageNo,
|
|
|
pageSize,
|
|
|
totalCount,
|
|
|
totalPage: Math.ceil(totalCount / pageSize),
|
|
|
message: GET_SUCCESS
|
|
|
});
|
|
|
});
|
|
|
})
|
|
|
.catch(next);
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 发布文章
|
|
|
* @param req
|
|
|
* @param res
|
...
|
...
|
|