|
@@ -21,7 +21,7 @@ class ArticleModel extends global.yoho.BaseModel { |
|
@@ -21,7 +21,7 @@ class ArticleModel extends global.yoho.BaseModel { |
21
|
* 获取文章列表
|
21
|
* 获取文章列表
|
22
|
* @returns {*}
|
22
|
* @returns {*}
|
23
|
*/
|
23
|
*/
|
24
|
- articleList({pageNo, pageSize, orderBy, order}) {
|
24
|
+ articleList({actId, pageNo, pageSize, orderBy, order}) {
|
25
|
const orderMapping = {
|
25
|
const orderMapping = {
|
26
|
goodCount: 'good_count',
|
26
|
goodCount: 'good_count',
|
27
|
createTime: 'create_time'
|
27
|
createTime: 'create_time'
|
|
@@ -29,7 +29,9 @@ class ArticleModel extends global.yoho.BaseModel { |
|
@@ -29,7 +29,9 @@ class ArticleModel extends global.yoho.BaseModel { |
29
|
|
29
|
|
30
|
let limitSql;
|
30
|
let limitSql;
|
31
|
let orderSql;
|
31
|
let orderSql;
|
|
|
32
|
+ let whereSql;
|
32
|
|
33
|
|
|
|
34
|
+ whereSql = `WHERE AA.act_id = ${actId}`;
|
33
|
orderSql = `ORDER BY AA.${orderMapping[orderBy]} ${order}`;
|
35
|
orderSql = `ORDER BY AA.${orderMapping[orderBy]} ${order}`;
|
34
|
limitSql = `LIMIT ${(pageNo - 1) * pageSize}, ${pageSize}`;
|
36
|
limitSql = `LIMIT ${(pageNo - 1) * pageSize}, ${pageSize}`;
|
35
|
|
37
|
|
|
@@ -39,7 +41,7 @@ class ArticleModel extends global.yoho.BaseModel { |
|
@@ -39,7 +41,7 @@ class ArticleModel extends global.yoho.BaseModel { |
39
|
FROM ${TABLE_ACT_ARTICLE} AS AA
|
41
|
FROM ${TABLE_ACT_ARTICLE} AS AA
|
40
|
INNER JOIN ${TABLE_ACT_ARTICLE_IMG} AS AAI
|
42
|
INNER JOIN ${TABLE_ACT_ARTICLE_IMG} AS AAI
|
41
|
ON AA.id = AAI.article_id
|
43
|
ON AA.id = AAI.article_id
|
42
|
- ${orderSql} ${limitSql};`
|
44
|
+ ${whereSql} ${orderSql} ${limitSql};`
|
43
|
);
|
45
|
);
|
44
|
}
|
46
|
}
|
45
|
|
47
|
|
|
@@ -47,9 +49,9 @@ class ArticleModel extends global.yoho.BaseModel { |
|
@@ -47,9 +49,9 @@ class ArticleModel extends global.yoho.BaseModel { |
47
|
* 获取文章总数
|
49
|
* 获取文章总数
|
48
|
* @returns {*}
|
50
|
* @returns {*}
|
49
|
*/
|
51
|
*/
|
50
|
- allArticlesNum() {
|
52
|
+ allArticlesNum(actId) {
|
51
|
return mysqlCli.query(
|
53
|
return mysqlCli.query(
|
52
|
- `SELECT COUNT(*) AS total FROM ${TABLE_ACT_ARTICLE};`
|
54
|
+ `SELECT COUNT(*) AS total FROM ${TABLE_ACT_ARTICLE} WHERE act_id = ${actId};`
|
53
|
).then(res => {
|
55
|
).then(res => {
|
54
|
return res[0].total;
|
56
|
return res[0].total;
|
55
|
});
|
57
|
});
|