...
|
...
|
@@ -31,9 +31,9 @@ class ArticleModel extends global.yoho.BaseModel { |
|
|
let orderSql;
|
|
|
let whereSql;
|
|
|
|
|
|
whereSql = `WHERE AA.act_id = ${actId}`;
|
|
|
whereSql = 'WHERE AA.act_id = :actId';
|
|
|
orderSql = `ORDER BY AA.${orderMapping[orderBy]} ${order}`;
|
|
|
limitSql = `LIMIT ${(pageNo - 1) * pageSize}, ${pageSize}`;
|
|
|
limitSql = 'LIMIT :start, :page';
|
|
|
|
|
|
return mysqlCli.query(
|
|
|
`SELECT
|
...
|
...
|
@@ -47,7 +47,11 @@ class ArticleModel extends global.yoho.BaseModel { |
|
|
INNER JOIN ${TABLE_ACT_ARTICLE_IMG} AAI
|
|
|
INNER JOIN ${TABLE_USER} USR
|
|
|
ON AA.id = AAI.article_id AND AA.user_id = USR.id
|
|
|
${whereSql} ${orderSql} ${limitSql};`
|
|
|
${whereSql} ${orderSql} ${limitSql};`, {
|
|
|
actId,
|
|
|
start: (pageNo - 1) * pageSize,
|
|
|
page: _.parseInt(pageSize)
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -57,7 +61,9 @@ class ArticleModel extends global.yoho.BaseModel { |
|
|
*/
|
|
|
allArticlesNum(actId) {
|
|
|
return mysqlCli.query(
|
|
|
`SELECT COUNT(*) AS total FROM ${TABLE_ACT_ARTICLE} WHERE act_id = ${actId};`
|
|
|
`SELECT COUNT(*) AS total FROM ${TABLE_ACT_ARTICLE} WHERE act_id = :actId;`, {
|
|
|
actId
|
|
|
}
|
|
|
).then(res => {
|
|
|
return res[0].total;
|
|
|
});
|
...
|
...
|
|