...
|
...
|
@@ -21,7 +21,7 @@ class ArticleModel extends global.yoho.BaseModel { |
|
|
* 获取文章列表
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
articleList({pageNo, pageSize, orderBy, order}) {
|
|
|
articleList({actId, pageNo, pageSize, orderBy, order}) {
|
|
|
const orderMapping = {
|
|
|
goodCount: 'good_count',
|
|
|
createTime: 'create_time'
|
...
|
...
|
@@ -29,7 +29,9 @@ class ArticleModel extends global.yoho.BaseModel { |
|
|
|
|
|
let limitSql;
|
|
|
let orderSql;
|
|
|
let whereSql;
|
|
|
|
|
|
whereSql = `WHERE AA.act_id = ${actId}`;
|
|
|
orderSql = `ORDER BY AA.${orderMapping[orderBy]} ${order}`;
|
|
|
limitSql = `LIMIT ${(pageNo - 1) * pageSize}, ${pageSize}`;
|
|
|
|
...
|
...
|
@@ -39,7 +41,7 @@ class ArticleModel extends global.yoho.BaseModel { |
|
|
FROM ${TABLE_ACT_ARTICLE} AS AA
|
|
|
INNER JOIN ${TABLE_ACT_ARTICLE_IMG} AS AAI
|
|
|
ON AA.id = AAI.article_id
|
|
|
${orderSql} ${limitSql};`
|
|
|
${whereSql} ${orderSql} ${limitSql};`
|
|
|
);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -47,9 +49,9 @@ class ArticleModel extends global.yoho.BaseModel { |
|
|
* 获取文章总数
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
allArticlesNum() {
|
|
|
allArticlesNum(actId) {
|
|
|
return mysqlCli.query(
|
|
|
`SELECT COUNT(*) AS total FROM ${TABLE_ACT_ARTICLE};`
|
|
|
`SELECT COUNT(*) AS total FROM ${TABLE_ACT_ARTICLE} WHERE act_id = ${actId};`
|
|
|
).then(res => {
|
|
|
return res[0].total;
|
|
|
});
|
...
|
...
|
|