Authored by 李奇

列表页返回添加用户昵称

@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 const _ = require('lodash'); 7 const _ = require('lodash');
8 const mysqlCli = global.yoho.utils.mysqlCli; 8 const mysqlCli = global.yoho.utils.mysqlCli;
9 9
  10 +const TABLE_USER = 'user';
10 const TABLE_ACT_ARTICLE = 'act_article'; 11 const TABLE_ACT_ARTICLE = 'act_article';
11 const TABLE_ACT_ARTICLE_IMG = 'act_article_img'; 12 const TABLE_ACT_ARTICLE_IMG = 'act_article_img';
12 13
@@ -41,10 +42,12 @@ class ArticleModel extends global.yoho.BaseModel { @@ -41,10 +42,12 @@ class ArticleModel extends global.yoho.BaseModel {
41 AA.good_count, 42 AA.good_count,
42 AAI.img_url, 43 AAI.img_url,
43 AA.content, 44 AA.content,
44 - AA.create_time  
45 - FROM ${TABLE_ACT_ARTICLE} AS AA  
46 - INNER JOIN ${TABLE_ACT_ARTICLE_IMG} AS AAI  
47 - ON AA.id = AAI.article_id 45 + AA.create_time,
  46 + USR.user_name
  47 + FROM ${TABLE_ACT_ARTICLE} AA
  48 + INNER JOIN ${TABLE_ACT_ARTICLE_IMG} AAI
  49 + INNER JOIN ${TABLE_USER} USR
  50 + ON AA.id = AAI.article_id AND AA.user_id = USR.id
48 ${whereSql} ${orderSql} ${limitSql};` 51 ${whereSql} ${orderSql} ${limitSql};`
49 ); 52 );
50 } 53 }
@@ -51,6 +51,10 @@ const userController = { @@ -51,6 +51,10 @@ const userController = {
51 51
52 req.ctx(UserModel).createUser(userInfo) 52 req.ctx(UserModel).createUser(userInfo)
53 .then((id) => { 53 .then((id) => {
  54 +
  55 + // 用户ID
  56 + _.set(req.session, 'user.id', id);
  57 +
54 res.json({ 58 res.json({
55 code: 200, 59 code: 200,
56 data: _.assign(userInfo, {id}), 60 data: _.assign(userInfo, {id}),