Authored by 邱骏

增加查询字段

@@ -11,7 +11,7 @@ const y100 = { @@ -11,7 +11,7 @@ const y100 = {
11 * @param next 11 * @param next
12 */ 12 */
13 async y100List(req, res, next) { 13 async y100List(req, res, next) {
14 - const {actId, pageNo = 1, pageSize = 10, tag = ''} = req.query; 14 + const {actId, pageNo = 1, pageSize = 10, tag = '', top = true} = req.query;
15 15
16 if (!actId) { 16 if (!actId) {
17 return res.json({ 17 return res.json({
@@ -25,7 +25,8 @@ const y100 = { @@ -25,7 +25,8 @@ const y100 = {
25 actId, 25 actId,
26 pageNo, 26 pageNo,
27 pageSize, 27 pageSize,
28 - tag 28 + tag,
  29 + top
29 }); 30 });
30 31
31 return res.json({ 32 return res.json({
@@ -16,7 +16,7 @@ class Y100Model extends global.yoho.BaseModel { @@ -16,7 +16,7 @@ class Y100Model extends global.yoho.BaseModel {
16 * 获取Y100列表 16 * 获取Y100列表
17 * @returns {*} 17 * @returns {*}
18 */ 18 */
19 - articleY100List({actId, pageNo, pageSize, tag}) { 19 + articleY100List({actId, pageNo, pageSize, tag, top}) {
20 const params = { 20 const params = {
21 actId, 21 actId,
22 start: (pageNo - 1) * pageSize, 22 start: (pageNo - 1) * pageSize,
@@ -28,7 +28,12 @@ class Y100Model extends global.yoho.BaseModel { @@ -28,7 +28,12 @@ class Y100Model extends global.yoho.BaseModel {
28 AA.good_count, 28 AA.good_count,
29 AA.create_time, 29 AA.create_time,
30 AAY.name, 30 AAY.name,
31 - AAY.img_url 31 + AAY.img_url,
  32 + AAY.career,
  33 + AAY.interest,
  34 + AAY.name,
  35 + AAY.style,
  36 + AAY.tag
32 FROM ${TABLE_ACT_ARTICLE} AA 37 FROM ${TABLE_ACT_ARTICLE} AA
33 INNER JOIN ${TABLE_ACT_ARTICLE_Y100} AAY ON AA.id = AAY.article_id 38 INNER JOIN ${TABLE_ACT_ARTICLE_Y100} AAY ON AA.id = AAY.article_id
34 WHERE AA.act_id = :actId`; 39 WHERE AA.act_id = :actId`;
@@ -36,12 +41,14 @@ class Y100Model extends global.yoho.BaseModel { @@ -36,12 +41,14 @@ class Y100Model extends global.yoho.BaseModel {
36 if (tag) { 41 if (tag) {
37 sql += ' and AAY.tag like :tag'; 42 sql += ' and AAY.tag like :tag';
38 params.tag = `%${tag}%`; 43 params.tag = `%${tag}%`;
39 - sql += ' ORDER BY AA.good_count DESC'; 44 +
  45 + }
  46 + if (top) {
  47 + sql += ' ORDER BY AAY.top DESC,AA.create_time DESC';
40 } else { 48 } else {
41 - sql += ' and AAY.top = 1'; 49 + sql += ' ORDER BY AA.good_count DESC';
42 } 50 }
43 sql += ' LIMIT :start, :page'; 51 sql += ' LIMIT :start, :page';
44 - console.log(sql, actId, pageNo, pageSize, tag);  
45 52
46 return mysqlCli.query(sql, params); 53 return mysqlCli.query(sql, params);
47 } 54 }