Showing
9 changed files
with
55 additions
and
129 deletions
@@ -8,7 +8,7 @@ const moment = require('moment'); | @@ -8,7 +8,7 @@ const moment = require('moment'); | ||
8 | const excelExport = require('excel-export'); | 8 | const excelExport = require('excel-export'); |
9 | const ActivityModel = require('../models/activity'); | 9 | const ActivityModel = require('../models/activity'); |
10 | 10 | ||
11 | -const POST_SUCCESS = '操作成功'; | 11 | +const DO_SUCCESS = '操作成功'; |
12 | const INVALID_PARAMS = '参数错误'; | 12 | const INVALID_PARAMS = '参数错误'; |
13 | 13 | ||
14 | const timeFormat = (time) => { | 14 | const timeFormat = (time) => { |
@@ -48,7 +48,7 @@ const activity = { | @@ -48,7 +48,7 @@ const activity = { | ||
48 | .then(() => { | 48 | .then(() => { |
49 | return res.json({ | 49 | return res.json({ |
50 | code: 200, | 50 | code: 200, |
51 | - message: POST_SUCCESS | 51 | + message: DO_SUCCESS |
52 | }); | 52 | }); |
53 | }) | 53 | }) |
54 | .catch(next); | 54 | .catch(next); |
@@ -109,7 +109,7 @@ const activity = { | @@ -109,7 +109,7 @@ const activity = { | ||
109 | .then(() => { | 109 | .then(() => { |
110 | return res.json({ | 110 | return res.json({ |
111 | code: 200, | 111 | code: 200, |
112 | - message: POST_SUCCESS | 112 | + message: DO_SUCCESS |
113 | }); | 113 | }); |
114 | }) | 114 | }) |
115 | .catch(next); | 115 | .catch(next); |
@@ -148,7 +148,7 @@ const activity = { | @@ -148,7 +148,7 @@ const activity = { | ||
148 | .then(() => { | 148 | .then(() => { |
149 | return res.json({ | 149 | return res.json({ |
150 | code: 200, | 150 | code: 200, |
151 | - message: POST_SUCCESS | 151 | + message: DO_SUCCESS |
152 | }); | 152 | }); |
153 | }) | 153 | }) |
154 | .catch(next); | 154 | .catch(next); |
@@ -197,9 +197,15 @@ const activity = { | @@ -197,9 +197,15 @@ const activity = { | ||
197 | 197 | ||
198 | req.ctx(ActivityModel).deleteArticle(id) | 198 | req.ctx(ActivityModel).deleteArticle(id) |
199 | .then(() => { | 199 | .then(() => { |
200 | - return res.json({ | 200 | + return req.ctx(ActivityModel).deleteArticleImg(id); |
201 | + }) | ||
202 | + .then(() => { | ||
203 | + return req.ctx(ActivityModel).deleteArticleLike(id); | ||
204 | + }) | ||
205 | + .then(() => { | ||
206 | + res.json({ | ||
201 | code: 200, | 207 | code: 200, |
202 | - message: POST_SUCCESS | 208 | + message: DO_SUCCESS |
203 | }); | 209 | }); |
204 | }) | 210 | }) |
205 | .catch(next); | 211 | .catch(next); |
@@ -270,25 +276,6 @@ const activity = { | @@ -270,25 +276,6 @@ const activity = { | ||
270 | }) | 276 | }) |
271 | .catch(next); | 277 | .catch(next); |
272 | 278 | ||
273 | - }, | ||
274 | - | ||
275 | - /** | ||
276 | - * 活动参与用户列表 | ||
277 | - * @param req | ||
278 | - * @param res | ||
279 | - * @param next | ||
280 | - */ | ||
281 | - activityUserListPage(req, res, next) { | ||
282 | - req.ctx(ActivityModel).activityList() | ||
283 | - .then(result => { | ||
284 | - res.render('activity/user-list', { | ||
285 | - bodyClass: 'nav-md', | ||
286 | - activityList: result, | ||
287 | - module: 'admin', | ||
288 | - page: 'activity' | ||
289 | - }); | ||
290 | - }) | ||
291 | - .catch(next); | ||
292 | } | 279 | } |
293 | }; | 280 | }; |
294 | 281 |
@@ -7,19 +7,6 @@ const _ = require('lodash'); | @@ -7,19 +7,6 @@ const _ = require('lodash'); | ||
7 | 7 | ||
8 | const adminController = { | 8 | const adminController = { |
9 | /** | 9 | /** |
10 | - * 首页 | ||
11 | - * @param req | ||
12 | - * @param res | ||
13 | - */ | ||
14 | - homePage(req, res) { | ||
15 | - res.render('home', { | ||
16 | - page: 'login', | ||
17 | - module: 'admin', | ||
18 | - bodyClass: 'nav-md' | ||
19 | - }); | ||
20 | - }, | ||
21 | - | ||
22 | - /** | ||
23 | * 登录页 | 10 | * 登录页 |
24 | * @param req | 11 | * @param req |
25 | * @param res | 12 | * @param res |
@@ -6,9 +6,11 @@ | @@ -6,9 +6,11 @@ | ||
6 | 6 | ||
7 | const mysqlCli = global.yoho.utils.mysqlCli; | 7 | const mysqlCli = global.yoho.utils.mysqlCli; |
8 | 8 | ||
9 | -const TABLE_ACTIVITY = 'activity'; | ||
10 | -const TABLE_ACT_ARTICLE = 'act_article'; | ||
11 | -const TABLE_USER = 'user'; | 9 | +const TB_USER = 'user'; |
10 | +const TB_ACTIVITY = 'activity'; | ||
11 | +const TB_ACT_ARTICLE = 'act_article'; | ||
12 | +const TB_ACT_ARTICLE_IMG = 'act_article_img'; | ||
13 | +const TB_ACT_ARTICLE_GOOD = 'act_article_good'; | ||
12 | 14 | ||
13 | class AdminModel extends global.yoho.BaseModel { | 15 | class AdminModel extends global.yoho.BaseModel { |
14 | constructor(ctx) { | 16 | constructor(ctx) { |
@@ -24,7 +26,7 @@ class AdminModel extends global.yoho.BaseModel { | @@ -24,7 +26,7 @@ class AdminModel extends global.yoho.BaseModel { | ||
24 | */ | 26 | */ |
25 | createActivity({title, startTime, endTime}) { | 27 | createActivity({title, startTime, endTime}) { |
26 | return mysqlCli.insert( | 28 | return mysqlCli.insert( |
27 | - `insert into ${TABLE_ACTIVITY} (title, start_time, end_time) values (:title, :startTime, :endTime);`, | 29 | + `insert into ${TB_ACTIVITY} (title, start_time, end_time) values (:title, :startTime, :endTime);`, |
28 | { | 30 | { |
29 | title, | 31 | title, |
30 | startTime, | 32 | startTime, |
@@ -39,7 +41,7 @@ class AdminModel extends global.yoho.BaseModel { | @@ -39,7 +41,7 @@ class AdminModel extends global.yoho.BaseModel { | ||
39 | */ | 41 | */ |
40 | activityList() { | 42 | activityList() { |
41 | return mysqlCli.query( | 43 | return mysqlCli.query( |
42 | - `select id, title, start_time startTime, end_time endTime, create_time createTime from ${TABLE_ACTIVITY};` | 44 | + `select id, title, start_time startTime, end_time endTime, create_time createTime from ${TB_ACTIVITY};` |
43 | ); | 45 | ); |
44 | } | 46 | } |
45 | 47 | ||
@@ -50,7 +52,7 @@ class AdminModel extends global.yoho.BaseModel { | @@ -50,7 +52,7 @@ class AdminModel extends global.yoho.BaseModel { | ||
50 | */ | 52 | */ |
51 | deleteActivity(actId) { | 53 | deleteActivity(actId) { |
52 | return mysqlCli.delete( | 54 | return mysqlCli.delete( |
53 | - `delete from ${TABLE_ACTIVITY} where id = :actId;`, | 55 | + `delete from ${TB_ACTIVITY} where id = :actId;`, |
54 | { | 56 | { |
55 | actId | 57 | actId |
56 | } | 58 | } |
@@ -65,8 +67,8 @@ class AdminModel extends global.yoho.BaseModel { | @@ -65,8 +67,8 @@ class AdminModel extends global.yoho.BaseModel { | ||
65 | return mysqlCli.query( | 67 | return mysqlCli.query( |
66 | `select taa.id, taa.create_time createTime, taa.good_count goodCount, | 68 | `select taa.id, taa.create_time createTime, taa.good_count goodCount, |
67 | tu.user_name userName, tu.user_phone phone | 69 | tu.user_name userName, tu.user_phone phone |
68 | - from ${TABLE_ACT_ARTICLE} taa | ||
69 | - left join ${TABLE_USER} tu | 70 | + from ${TB_ACT_ARTICLE} taa |
71 | + left join ${TB_USER} tu | ||
70 | on taa.user_id = tu.id | 72 | on taa.user_id = tu.id |
71 | where act_id = :actId;`, { | 73 | where act_id = :actId;`, { |
72 | actId | 74 | actId |
@@ -81,7 +83,7 @@ class AdminModel extends global.yoho.BaseModel { | @@ -81,7 +83,7 @@ class AdminModel extends global.yoho.BaseModel { | ||
81 | */ | 83 | */ |
82 | deleteArticle(id) { | 84 | deleteArticle(id) { |
83 | return mysqlCli.delete( | 85 | return mysqlCli.delete( |
84 | - `delete from ${TABLE_ACT_ARTICLE} where id = :id;`, | 86 | + `delete from ${TB_ACT_ARTICLE} where id = :id;`, |
85 | { | 87 | { |
86 | id | 88 | id |
87 | } | 89 | } |
@@ -89,19 +91,29 @@ class AdminModel extends global.yoho.BaseModel { | @@ -89,19 +91,29 @@ class AdminModel extends global.yoho.BaseModel { | ||
89 | } | 91 | } |
90 | 92 | ||
91 | /** | 93 | /** |
92 | - * 参与活动用户列表 | 94 | + * 删除文章图片 |
95 | + * @param id 文章ID | ||
93 | * @returns {*} | 96 | * @returns {*} |
94 | */ | 97 | */ |
95 | - activityUserList(actId) { | ||
96 | - return mysqlCli.query( | ||
97 | - `select tu.user_phone phone | ||
98 | - from ${TABLE_ACTIVITY} ta | ||
99 | - inner join act_article taa | ||
100 | - on ta.id = taa.act_id | ||
101 | - inner join user tu | ||
102 | - on taa.user_id = tu.id | ||
103 | - where ta.id = :actId;`, { | ||
104 | - actId | 98 | + deleteArticleImg(id) { |
99 | + return mysqlCli.delete( | ||
100 | + `delete from ${TB_ACT_ARTICLE_IMG} where article_id = :id;`, | ||
101 | + { | ||
102 | + id | ||
103 | + } | ||
104 | + ); | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
108 | + * 删除文章点赞信息 | ||
109 | + * @param id 文章ID | ||
110 | + * @returns {*} | ||
111 | + */ | ||
112 | + deleteArticleLike(id) { | ||
113 | + return mysqlCli.delete( | ||
114 | + `delete from ${TB_ACT_ARTICLE_GOOD} where article_id = :id;`, | ||
115 | + { | ||
116 | + id | ||
105 | } | 117 | } |
106 | ); | 118 | ); |
107 | } | 119 | } |
@@ -9,20 +9,19 @@ const admin = require('./controllers/admin'); | @@ -9,20 +9,19 @@ const admin = require('./controllers/admin'); | ||
9 | const activity = require('./controllers/activity'); | 9 | const activity = require('./controllers/activity'); |
10 | const user = require('./controllers/user'); | 10 | const user = require('./controllers/user'); |
11 | 11 | ||
12 | +// 管理员[page] | ||
12 | router.get('/login', admin.loginPage); | 13 | router.get('/login', admin.loginPage); |
13 | -router.get('/home', admin.homePage); | ||
14 | 14 | ||
15 | - | ||
16 | - | ||
17 | -// 活动管理[menu] | 15 | +// 活动管理[page] |
18 | router.get('/activity/list', activity.activityListPage); | 16 | router.get('/activity/list', activity.activityListPage); |
19 | router.get('/activity/create', activity.createActivityPage); | 17 | router.get('/activity/create', activity.createActivityPage); |
20 | router.get('/activity/article', activity.actArticleListPage); | 18 | router.get('/activity/article', activity.actArticleListPage); |
21 | 19 | ||
22 | -// 用户管理[menu] | 20 | +// 用户管理[page] |
23 | router.get('/user/list', user.userListPage); | 21 | router.get('/user/list', user.userListPage); |
24 | 22 | ||
25 | -// ajax | 23 | + |
24 | +// 管理员[ajax] | ||
26 | router.post('/api/login', admin.login); | 25 | router.post('/api/login', admin.login); |
27 | router.post('/api/logout', admin.logout); | 26 | router.post('/api/logout', admin.logout); |
28 | 27 | ||
@@ -33,7 +32,6 @@ router.post('/api/activity/delete', activity.deleteActivity); | @@ -33,7 +32,6 @@ router.post('/api/activity/delete', activity.deleteActivity); | ||
33 | router.post('/api/activity/deleteArticle', activity.deleteArticle); | 32 | router.post('/api/activity/deleteArticle', activity.deleteArticle); |
34 | router.get('/api/activity/exportArticleList', activity.exportArticleList); | 33 | router.get('/api/activity/exportArticleList', activity.exportArticleList); |
35 | 34 | ||
36 | - | ||
37 | // 用户管理[ajax] | 35 | // 用户管理[ajax] |
38 | router.post('/api/user/delete', user.deleteUser); | 36 | router.post('/api/user/delete', user.deleteUser); |
39 | router.get('/api/user/exportUserList', user.exportUserList); | 37 | router.get('/api/user/exportUserList', user.exportUserList); |
@@ -5,13 +5,12 @@ | @@ -5,13 +5,12 @@ | ||
5 | <div class="col-md-12 col-sm-12 col-xs-12"> | 5 | <div class="col-md-12 col-sm-12 col-xs-12"> |
6 | <div class="x_panel"> | 6 | <div class="x_panel"> |
7 | <div class="x_title"> | 7 | <div class="x_title"> |
8 | - <h2>文章列表</h2> | 8 | + <button class="btn btn-success btn-export-article" data-id="{{actId}}">导出文章列表</button> |
9 | <div class="clearfix"></div> | 9 | <div class="clearfix"></div> |
10 | </div> | 10 | </div> |
11 | - <button class="btn btn-primary btn-export-article" data-id="{{actId}}">导出列表</button> | ||
12 | <div class="x_content"> | 11 | <div class="x_content"> |
13 | <div class="table-responsive"> | 12 | <div class="table-responsive"> |
14 | - <table class="table table-striped jambo_table bulk_action"> | 13 | + <table class="table table-bordered"> |
15 | <thead> | 14 | <thead> |
16 | <tr class="headings"> | 15 | <tr class="headings"> |
17 | <th class="column-title">文章ID</th> | 16 | <th class="column-title">文章ID</th> |
@@ -4,14 +4,9 @@ | @@ -4,14 +4,9 @@ | ||
4 | <div class="row"> | 4 | <div class="row"> |
5 | <div class="col-md-12 col-sm-12 col-xs-12"> | 5 | <div class="col-md-12 col-sm-12 col-xs-12"> |
6 | <div class="x_panel"> | 6 | <div class="x_panel"> |
7 | - <div class="x_title"> | ||
8 | - <h2>活动列表</h2> | ||
9 | - <div class="clearfix"></div> | ||
10 | - </div> | ||
11 | - | ||
12 | <div class="x_content"> | 7 | <div class="x_content"> |
13 | <div class="table-responsive"> | 8 | <div class="table-responsive"> |
14 | - <table class="table table-striped jambo_table bulk_action"> | 9 | + <table class="table table-bordered"> |
15 | <thead> | 10 | <thead> |
16 | <tr class="headings"> | 11 | <tr class="headings"> |
17 | <th class="column-title">活动ID</th> | 12 | <th class="column-title">活动ID</th> |
apps/admin/views/action/home.hbs
deleted
100644 → 0
1 | -<!-- page content --> | ||
2 | -<div class="right_col" role="main"> | ||
3 | - <div class=""> | ||
4 | - <div class="page-title"> | ||
5 | - <div class="title_left"> | ||
6 | - <h3>Plain Page</h3> | ||
7 | - </div> | ||
8 | - <div class="title_right"> | ||
9 | - <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search"> | ||
10 | - <div class="input-group"> | ||
11 | - <input type="text" class="form-control" placeholder="Search for..."> | ||
12 | - <span class="input-group-btn"> | ||
13 | - <button class="btn btn-default" type="button">Go!</button> | ||
14 | - </span> | ||
15 | - </div> | ||
16 | - </div> | ||
17 | - </div> | ||
18 | - </div> | ||
19 | - | ||
20 | - <div class="clearfix"></div> | ||
21 | - <div class="row"> | ||
22 | - <div class="col-md-12 col-sm-12 col-xs-12"> | ||
23 | - <div class="x_panel"> | ||
24 | - <div class="x_title"> | ||
25 | - <h2>Plain Page</h2> | ||
26 | - <ul class="nav navbar-right panel_toolbox"> | ||
27 | - <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a> | ||
28 | - </li> | ||
29 | - <li class="dropdown"> | ||
30 | - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a> | ||
31 | - <ul class="dropdown-menu" role="menu"> | ||
32 | - <li><a href="#">Settings 1</a> | ||
33 | - </li> | ||
34 | - <li><a href="#">Settings 2</a> | ||
35 | - </li> | ||
36 | - </ul> | ||
37 | - </li> | ||
38 | - <li><a class="close-link"><i class="fa fa-close"></i></a> | ||
39 | - </li> | ||
40 | - </ul> | ||
41 | - <div class="clearfix"></div> | ||
42 | - </div> | ||
43 | - <div class="x_content"> | ||
44 | - Add content to the page ... | ||
45 | - </div> | ||
46 | - </div> | ||
47 | - </div> | ||
48 | - </div> | ||
49 | - </div> | ||
50 | -</div> | ||
51 | -<!-- /page content --> |
@@ -5,13 +5,12 @@ | @@ -5,13 +5,12 @@ | ||
5 | <div class="col-md-12 col-sm-12 col-xs-12"> | 5 | <div class="col-md-12 col-sm-12 col-xs-12"> |
6 | <div class="x_panel"> | 6 | <div class="x_panel"> |
7 | <div class="x_title"> | 7 | <div class="x_title"> |
8 | - <h2>用户列表</h2> | 8 | + <button class="btn btn-success btn-export-user-list" data-id="{{id}}">导出用户列表</button> |
9 | <div class="clearfix"></div> | 9 | <div class="clearfix"></div> |
10 | </div> | 10 | </div> |
11 | - <button class="btn btn-primary btn-export-user-list" data-id="{{id}}">导出列表</button> | ||
12 | <div class="x_content"> | 11 | <div class="x_content"> |
13 | <div class="table-responsive"> | 12 | <div class="table-responsive"> |
14 | - <table class="table table-striped jambo_table bulk_action"> | 13 | + <table class="table table-bordered"> |
15 | <thead> | 14 | <thead> |
16 | <tr class="headings"> | 15 | <tr class="headings"> |
17 | <th class="column-title">ID</th> | 16 | <th class="column-title">ID</th> |
@@ -53,7 +53,7 @@ | @@ -53,7 +53,7 @@ | ||
53 | <li><a href="/admin/activity/create">活动创建</a></li> | 53 | <li><a href="/admin/activity/create">活动创建</a></li> |
54 | </ul> | 54 | </ul> |
55 | </li> | 55 | </li> |
56 | - <li><a><i class="fa fa-edit"></i> 用户管理 <span class="fa fa-chevron-down"></span></a> | 56 | + <li><a><i class="fa fa-users"></i> 用户管理 <span class="fa fa-chevron-down"></span></a> |
57 | <ul class="nav child_menu"> | 57 | <ul class="nav child_menu"> |
58 | <li><a href="/admin/user/list">用户列表</a></li> | 58 | <li><a href="/admin/user/list">用户列表</a></li> |
59 | </ul> | 59 | </ul> |
-
Please register or login to post a comment