Authored by 李奇

列表修改

... ... @@ -8,7 +8,7 @@ const moment = require('moment');
const excelExport = require('excel-export');
const ActivityModel = require('../models/activity');
const POST_SUCCESS = '操作成功';
const DO_SUCCESS = '操作成功';
const INVALID_PARAMS = '参数错误';
const timeFormat = (time) => {
... ... @@ -48,7 +48,7 @@ const activity = {
.then(() => {
return res.json({
code: 200,
message: POST_SUCCESS
message: DO_SUCCESS
});
})
.catch(next);
... ... @@ -109,7 +109,7 @@ const activity = {
.then(() => {
return res.json({
code: 200,
message: POST_SUCCESS
message: DO_SUCCESS
});
})
.catch(next);
... ... @@ -148,7 +148,7 @@ const activity = {
.then(() => {
return res.json({
code: 200,
message: POST_SUCCESS
message: DO_SUCCESS
});
})
.catch(next);
... ... @@ -197,9 +197,15 @@ const activity = {
req.ctx(ActivityModel).deleteArticle(id)
.then(() => {
return res.json({
return req.ctx(ActivityModel).deleteArticleImg(id);
})
.then(() => {
return req.ctx(ActivityModel).deleteArticleLike(id);
})
.then(() => {
res.json({
code: 200,
message: POST_SUCCESS
message: DO_SUCCESS
});
})
.catch(next);
... ... @@ -270,25 +276,6 @@ const activity = {
})
.catch(next);
},
/**
* 活动参与用户列表
* @param req
* @param res
* @param next
*/
activityUserListPage(req, res, next) {
req.ctx(ActivityModel).activityList()
.then(result => {
res.render('activity/user-list', {
bodyClass: 'nav-md',
activityList: result,
module: 'admin',
page: 'activity'
});
})
.catch(next);
}
};
... ...
... ... @@ -7,19 +7,6 @@ const _ = require('lodash');
const adminController = {
/**
* 首页
* @param req
* @param res
*/
homePage(req, res) {
res.render('home', {
page: 'login',
module: 'admin',
bodyClass: 'nav-md'
});
},
/**
* 登录页
* @param req
* @param res
... ...
... ... @@ -6,9 +6,11 @@
const mysqlCli = global.yoho.utils.mysqlCli;
const TABLE_ACTIVITY = 'activity';
const TABLE_ACT_ARTICLE = 'act_article';
const TABLE_USER = 'user';
const TB_USER = 'user';
const TB_ACTIVITY = 'activity';
const TB_ACT_ARTICLE = 'act_article';
const TB_ACT_ARTICLE_IMG = 'act_article_img';
const TB_ACT_ARTICLE_GOOD = 'act_article_good';
class AdminModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -24,7 +26,7 @@ class AdminModel extends global.yoho.BaseModel {
*/
createActivity({title, startTime, endTime}) {
return mysqlCli.insert(
`insert into ${TABLE_ACTIVITY} (title, start_time, end_time) values (:title, :startTime, :endTime);`,
`insert into ${TB_ACTIVITY} (title, start_time, end_time) values (:title, :startTime, :endTime);`,
{
title,
startTime,
... ... @@ -39,7 +41,7 @@ class AdminModel extends global.yoho.BaseModel {
*/
activityList() {
return mysqlCli.query(
`select id, title, start_time startTime, end_time endTime, create_time createTime from ${TABLE_ACTIVITY};`
`select id, title, start_time startTime, end_time endTime, create_time createTime from ${TB_ACTIVITY};`
);
}
... ... @@ -50,7 +52,7 @@ class AdminModel extends global.yoho.BaseModel {
*/
deleteActivity(actId) {
return mysqlCli.delete(
`delete from ${TABLE_ACTIVITY} where id = :actId;`,
`delete from ${TB_ACTIVITY} where id = :actId;`,
{
actId
}
... ... @@ -65,8 +67,8 @@ class AdminModel extends global.yoho.BaseModel {
return mysqlCli.query(
`select taa.id, taa.create_time createTime, taa.good_count goodCount,
tu.user_name userName, tu.user_phone phone
from ${TABLE_ACT_ARTICLE} taa
left join ${TABLE_USER} tu
from ${TB_ACT_ARTICLE} taa
left join ${TB_USER} tu
on taa.user_id = tu.id
where act_id = :actId;`, {
actId
... ... @@ -81,7 +83,7 @@ class AdminModel extends global.yoho.BaseModel {
*/
deleteArticle(id) {
return mysqlCli.delete(
`delete from ${TABLE_ACT_ARTICLE} where id = :id;`,
`delete from ${TB_ACT_ARTICLE} where id = :id;`,
{
id
}
... ... @@ -89,19 +91,29 @@ class AdminModel extends global.yoho.BaseModel {
}
/**
* 参与活动用户列表
* 删除文章图片
* @param id 文章ID
* @returns {*}
*/
activityUserList(actId) {
return mysqlCli.query(
`select tu.user_phone phone
from ${TABLE_ACTIVITY} ta
inner join act_article taa
on ta.id = taa.act_id
inner join user tu
on taa.user_id = tu.id
where ta.id = :actId;`, {
actId
deleteArticleImg(id) {
return mysqlCli.delete(
`delete from ${TB_ACT_ARTICLE_IMG} where article_id = :id;`,
{
id
}
);
}
/**
* 删除文章点赞信息
* @param id 文章ID
* @returns {*}
*/
deleteArticleLike(id) {
return mysqlCli.delete(
`delete from ${TB_ACT_ARTICLE_GOOD} where article_id = :id;`,
{
id
}
);
}
... ...
... ... @@ -9,20 +9,19 @@ const admin = require('./controllers/admin');
const activity = require('./controllers/activity');
const user = require('./controllers/user');
// 管理员[page]
router.get('/login', admin.loginPage);
router.get('/home', admin.homePage);
// 活动管理[menu]
// 活动管理[page]
router.get('/activity/list', activity.activityListPage);
router.get('/activity/create', activity.createActivityPage);
router.get('/activity/article', activity.actArticleListPage);
// 用户管理[menu]
// 用户管理[page]
router.get('/user/list', user.userListPage);
// ajax
// 管理员[ajax]
router.post('/api/login', admin.login);
router.post('/api/logout', admin.logout);
... ... @@ -33,7 +32,6 @@ router.post('/api/activity/delete', activity.deleteActivity);
router.post('/api/activity/deleteArticle', activity.deleteArticle);
router.get('/api/activity/exportArticleList', activity.exportArticleList);
// 用户管理[ajax]
router.post('/api/user/delete', user.deleteUser);
router.get('/api/user/exportUserList', user.exportUserList);
... ...
... ... @@ -5,13 +5,12 @@
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>文章列表</h2>
<button class="btn btn-success btn-export-article" data-id="{{actId}}">导出文章列表</button>
<div class="clearfix"></div>
</div>
<button class="btn btn-primary btn-export-article" data-id="{{actId}}">导出列表</button>
<div class="x_content">
<div class="table-responsive">
<table class="table table-striped jambo_table bulk_action">
<table class="table table-bordered">
<thead>
<tr class="headings">
<th class="column-title">文章ID</th>
... ...
... ... @@ -4,14 +4,9 @@
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>活动列表</h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="table-responsive">
<table class="table table-striped jambo_table bulk_action">
<table class="table table-bordered">
<thead>
<tr class="headings">
<th class="column-title">活动ID</th>
... ...
<!-- page content -->
<div class="right_col" role="main">
<div class="">
<div class="page-title">
<div class="title_left">
<h3>Plain Page</h3>
</div>
<div class="title_right">
<div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>Plain Page</h2>
<ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Settings 1</a>
</li>
<li><a href="#">Settings 2</a>
</li>
</ul>
</li>
<li><a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
Add content to the page ...
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /page content -->
... ... @@ -5,13 +5,12 @@
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>用户列表</h2>
<button class="btn btn-success btn-export-user-list" data-id="{{id}}">导出用户列表</button>
<div class="clearfix"></div>
</div>
<button class="btn btn-primary btn-export-user-list" data-id="{{id}}">导出列表</button>
<div class="x_content">
<div class="table-responsive">
<table class="table table-striped jambo_table bulk_action">
<table class="table table-bordered">
<thead>
<tr class="headings">
<th class="column-title">ID</th>
... ...
... ... @@ -53,7 +53,7 @@
<li><a href="/admin/activity/create">活动创建</a></li>
</ul>
</li>
<li><a><i class="fa fa-edit"></i> 用户管理 <span class="fa fa-chevron-down"></span></a>
<li><a><i class="fa fa-users"></i> 用户管理 <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="/admin/user/list">用户列表</a></li>
</ul>
... ...