Showing
4 changed files
with
23 additions
and
15 deletions
@@ -10,6 +10,14 @@ const AdminModel = require('../models/admin'); | @@ -10,6 +10,14 @@ const AdminModel = require('../models/admin'); | ||
10 | const POST_SUCCESS = '操作成功'; | 10 | const POST_SUCCESS = '操作成功'; |
11 | const INVALID_PARAMS = '参数错误'; | 11 | const INVALID_PARAMS = '参数错误'; |
12 | 12 | ||
13 | +const timeFormat = (time) => { | ||
14 | + if (_.isNumber(time)) { | ||
15 | + time = moment.unix(time); | ||
16 | + } | ||
17 | + | ||
18 | + return moment(time).format('YYYY-MM-DD HH:mm:ss'); | ||
19 | +}; | ||
20 | + | ||
13 | const article = { | 21 | const article = { |
14 | /** | 22 | /** |
15 | * 首页 | 23 | * 首页 |
@@ -124,20 +132,14 @@ const article = { | @@ -124,20 +132,14 @@ const article = { | ||
124 | * @param next | 132 | * @param next |
125 | */ | 133 | */ |
126 | activityListPage(req, res, next) { | 134 | activityListPage(req, res, next) { |
127 | - const _timeFormat = (time) => { | ||
128 | - if (_.isNumber(time)) { | ||
129 | - time = moment.unix(time); | ||
130 | - } | ||
131 | 135 | ||
132 | - return moment(time).format('YYYY-MM-DD HH:mm:ss'); | ||
133 | - }; | ||
134 | 136 | ||
135 | req.ctx(AdminModel).activityList() | 137 | req.ctx(AdminModel).activityList() |
136 | .then(result => { | 138 | .then(result => { |
137 | _.each(result, item => { | 139 | _.each(result, item => { |
138 | - item.endTime = _timeFormat(item.endTime); | ||
139 | - item.startTime = _timeFormat(item.startTime); | ||
140 | - item.createTime = _timeFormat(item.createTime); | 140 | + item.endTime = timeFormat(item.endTime); |
141 | + item.startTime = timeFormat(item.startTime); | ||
142 | + item.createTime = timeFormat(item.createTime); | ||
141 | }); | 143 | }); |
142 | 144 | ||
143 | res.render('activity/list', { | 145 | res.render('activity/list', { |
@@ -234,6 +236,9 @@ const article = { | @@ -234,6 +236,9 @@ const article = { | ||
234 | 236 | ||
235 | req.ctx(AdminModel).actArticleList(actId) | 237 | req.ctx(AdminModel).actArticleList(actId) |
236 | .then(result => { | 238 | .then(result => { |
239 | + _.each(result, item => { | ||
240 | + item.createTime = timeFormat(item.createTime); | ||
241 | + }); | ||
237 | res.render('activity/article-list', { | 242 | res.render('activity/article-list', { |
238 | bodyClass: 'nav-md', | 243 | bodyClass: 'nav-md', |
239 | articleList: result, | 244 | articleList: result, |
@@ -63,7 +63,8 @@ class AdminModel extends global.yoho.BaseModel { | @@ -63,7 +63,8 @@ class AdminModel extends global.yoho.BaseModel { | ||
63 | */ | 63 | */ |
64 | actArticleList(actId) { | 64 | actArticleList(actId) { |
65 | return mysqlCli.query( | 65 | return mysqlCli.query( |
66 | - `select taa.id, taa.content, taa.good_count goodCount, tu.user_name userName | 66 | + `select taa.id, taa.create_time createTime, taa.good_count goodCount, |
67 | + tu.user_name userName, tu.user_phone phone | ||
67 | from ${TABLE_ACT_ARTICLE} taa | 68 | from ${TABLE_ACT_ARTICLE} taa |
68 | inner join ${TABLE_USER} tu | 69 | inner join ${TABLE_USER} tu |
69 | on taa.user_id = tu.id | 70 | on taa.user_id = tu.id |
@@ -15,9 +15,10 @@ | @@ -15,9 +15,10 @@ | ||
15 | <thead> | 15 | <thead> |
16 | <tr class="headings"> | 16 | <tr class="headings"> |
17 | <th class="column-title">文章ID</th> | 17 | <th class="column-title">文章ID</th> |
18 | - <th class="column-title">文章内容</th> | ||
19 | - <th class="column-title">文章赞数</th> | ||
20 | - <th class="column-title">文章发布者</th> | 18 | + <th class="column-title">赞数</th> |
19 | + <th class="column-title">发布者</th> | ||
20 | + <th class="column-title">手机号</th> | ||
21 | + <th class="column-title">创建时间</th> | ||
21 | <th class="column-title">操作</th> | 22 | <th class="column-title">操作</th> |
22 | </tr> | 23 | </tr> |
23 | </thead> | 24 | </thead> |
@@ -26,9 +27,10 @@ | @@ -26,9 +27,10 @@ | ||
26 | {{#each articleList}} | 27 | {{#each articleList}} |
27 | <tr class="even pointer"> | 28 | <tr class="even pointer"> |
28 | <td>{{id}}</td> | 29 | <td>{{id}}</td> |
29 | - <td>{{content}}</td> | ||
30 | <td>{{goodCount}}</td> | 30 | <td>{{goodCount}}</td> |
31 | <td>{{userName}}</td> | 31 | <td>{{userName}}</td> |
32 | + <td>{{phone}}</td> | ||
33 | + <td>{{createTime}}</td> | ||
32 | <td> | 34 | <td> |
33 | <button class="btn btn-danger btn-delete-article" data-id="{{id}}">删除文章 | 35 | <button class="btn btn-danger btn-delete-article" data-id="{{id}}">删除文章 |
34 | </button> | 36 | </button> |
@@ -159,7 +159,7 @@ class ArticleModel extends global.yoho.BaseModel { | @@ -159,7 +159,7 @@ class ArticleModel extends global.yoho.BaseModel { | ||
159 | */ | 159 | */ |
160 | insertLikeDetail(actId, articleId) { | 160 | insertLikeDetail(actId, articleId) { |
161 | const userId = _.get(this.ctx.req.session, 'user.id', 0); | 161 | const userId = _.get(this.ctx.req.session, 'user.id', 0); |
162 | - const ip = this.header['X-Forwarded-For'] || this.ctx.req.connection.remoteAddress; | 162 | + const ip = this.header['X-Forwarded-For'] || this.ctx.req.ip || this.ctx.req.connection.remoteAddress; |
163 | 163 | ||
164 | return mysqlCli.insert( | 164 | return mysqlCli.insert( |
165 | `INSERT INTO ${TABLE_ACT_ARTICLE_GOOD} (act_id, article_id, user_id, ip) | 165 | `INSERT INTO ${TABLE_ACT_ARTICLE_GOOD} (act_id, article_id, user_id, ip) |
-
Please register or login to post a comment