...
|
...
|
@@ -21,8 +21,25 @@ class ArticleModel extends global.yoho.BaseModel { |
|
|
* 获取文章列表
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
articleList() {
|
|
|
return mysqlCli.query(`select * from ${TABLE_ACT_ARTICLE}`);
|
|
|
articleList({pageNo, pageSize, isPopular, orderBy, order}) {
|
|
|
let limitSql;
|
|
|
let whereSql = '';
|
|
|
let orderSql = `ORDER BY AA.${orderBy} ${order}`;
|
|
|
|
|
|
if (isPopular) {
|
|
|
whereSql = 'WHERE AA.good_count > 10';
|
|
|
}
|
|
|
|
|
|
limitSql = `LIMIT ${(pageNo - 1) * pageSize}, ${pageSize}`;
|
|
|
|
|
|
return mysqlCli.query(
|
|
|
`SELECT AA.id, AA.good_count goodCount,
|
|
|
AAI.img_url imgUrl, AA.content
|
|
|
FROM ${TABLE_ACT_ARTICLE} AS AA
|
|
|
INNER JOIN ${TABLE_ACT_ARTICLE_IMG} AS AAI
|
|
|
ON AA.id = AAI.article_id
|
|
|
${whereSql} ${orderSql} ${limitSql};`
|
|
|
);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|