Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-activity-platform
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
李奇
8 years ago
Commit
95b510d050bb97bee8a0208c91afe2deea9c7967
1 parent
e9572d7d
文章列表添加
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
249 additions
and
11 deletions
apps/admin/controllers/admin.js
apps/admin/models/admin.js
apps/admin/router.js
apps/admin/views/action/activity/article-list.hbs
apps/admin/views/action/activity/list.hbs
apps/admin/views/action/activity/user-list.hbs
public/js/admin/activity.page.js
apps/admin/controllers/admin.js
View file @
95b510d
...
...
@@ -208,6 +208,72 @@ const article = {
});
})
.
catch
(
next
);
},
/**
* 活动文章列表
* @param req
* @param res
* @param next
*/
actArticleListPage
(
req
,
res
,
next
)
{
const
actId
=
req
.
query
.
actId
;
req
.
ctx
(
AdminModel
).
actArticleList
(
actId
)
.
then
(
result
=>
{
res
.
render
(
'activity/article-list'
,
{
bodyClass
:
'nav-md'
,
articleList
:
result
,
module
:
'admin'
,
page
:
'activity'
});
})
.
catch
(
next
);
},
/**
* 删除文章
* @param req
* @param res
* @param next
*/
deleteArticle
(
req
,
res
,
next
)
{
const
id
=
req
.
body
.
id
;
if
(
!
id
)
{
return
res
.
json
({
code
:
400
,
message
:
INVALID_PARAMS
});
}
req
.
ctx
(
AdminModel
).
deleteArticle
(
id
)
.
then
(()
=>
{
return
res
.
json
({
code
:
200
,
message
:
POST_SUCCESS
});
})
.
catch
(
next
);
},
/**
* 活动参与用户列表
* @param req
* @param res
* @param next
*/
activityUserListPage
(
req
,
res
,
next
)
{
req
.
ctx
(
AdminModel
).
activityList
()
.
then
(
result
=>
{
res
.
render
(
'activity/user-list'
,
{
bodyClass
:
'nav-md'
,
activityList
:
result
,
module
:
'admin'
,
page
:
'activity'
});
})
.
catch
(
next
);
}
};
...
...
apps/admin/models/admin.js
View file @
95b510d
...
...
@@ -7,6 +7,8 @@
const
mysqlCli
=
global
.
yoho
.
utils
.
mysqlCli
;
const
TABLE_ACTIVITY
=
'activity'
;
const
TABLE_ACT_ARTICLE
=
'act_article'
;
const
TABLE_USER
=
'user'
;
class
AdminModel
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
...
...
@@ -54,6 +56,54 @@ class AdminModel extends global.yoho.BaseModel {
}
);
}
/**
* 活动文章列表
* @returns {*}
*/
actArticleList
(
actId
)
{
return
mysqlCli
.
query
(
`
select
taa
.
id
,
taa
.
content
,
taa
.
good_count
goodCount
,
tu
.
user_name
userName
from
$
{
TABLE_ACT_ARTICLE
}
taa
inner
join
$
{
TABLE_USER
}
tu
on
taa
.
user_id
=
tu
.
id
where
act_id
=
:
actId
;
`
,
{
actId
}
);
}
/**
* 删除文章
* @param id 文章ID
* @returns {*}
*/
deleteArticle
(
id
)
{
return
mysqlCli
.
delete
(
`
delete
from
$
{
TABLE_ACT_ARTICLE
}
where
id
=
:
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
}
);
}
}
module
.
exports
=
AdminModel
;
...
...
apps/admin/router.js
View file @
95b510d
...
...
@@ -13,6 +13,8 @@ router.get('/home', admin.homePage);
// 活动管理
router
.
get
(
'/activity/list'
,
admin
.
activityListPage
);
router
.
get
(
'/activity/create'
,
admin
.
createActivityPage
);
router
.
get
(
'/activity/user'
,
admin
.
activityUserListPage
);
router
.
get
(
'/activity/article'
,
admin
.
actArticleListPage
);
// ajax
router
.
post
(
'/api/login'
,
admin
.
login
);
...
...
@@ -20,5 +22,6 @@ router.post('/api/logout', admin.logout);
router
.
post
(
'/api/activity/list'
,
admin
.
activityList
);
router
.
post
(
'/api/activity/create'
,
admin
.
createActivity
);
router
.
post
(
'/api/activity/delete'
,
admin
.
deleteActivity
);
router
.
post
(
'/api/activity/deleteArticle'
,
admin
.
deleteArticle
);
module
.
exports
=
router
;
...
...
apps/admin/views/action/activity/article-list.hbs
0 → 100644
View file @
95b510d
<!-- page content -->
<div
class=
"right_col"
role=
"main"
>
<div
class=
""
>
<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"
>
<thead>
<tr
class=
"headings"
>
<th
class=
"column-title"
>
文章ID
</th>
<th
class=
"column-title"
>
文章内容
</th>
<th
class=
"column-title"
>
文章赞数
</th>
<th
class=
"column-title"
>
文章发布者
</th>
<th
class=
"column-title"
>
操作
</th>
</tr>
</thead>
<tbody>
{{#
each
articleList
}}
<tr
class=
"even pointer"
>
<td>
{{
id
}}
</td>
<td>
{{
content
}}
</td>
<td>
{{
goodCount
}}
</td>
<td>
{{
userName
}}
</td>
<td>
<button
class=
"btn btn-danger btn-delete-article"
data-id=
"
{{
id
}}
"
>
删除文章
</button>
</td>
</tr>
{{/
each
}}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /page content -->
...
...
apps/admin/views/action/activity/list.hbs
View file @
95b510d
...
...
@@ -18,7 +18,6 @@
<th
class=
"column-title"
>
开始时间
</th>
<th
class=
"column-title"
>
结束时间
</th>
<th
class=
"column-title"
>
创建时间
</th>
<th
class=
"column-title"
>
活动状态
</th>
<th
class=
"column-title"
>
操作
</th>
</tr>
</thead>
...
...
@@ -26,15 +25,13 @@
<tbody>
{{#
each
activityList
}}
<tr
class=
"even pointer"
>
<td
class=
" "
>
{{
title
}}
</td>
<td
class=
" "
>
{{
startTime
}}
</td>
<td
class=
" "
>
{{
endTime
}}
</td>
<td
class=
" "
>
{{
createTime
}}
</td>
<td
class=
" "
>
未开始
</td>
<td
class=
" "
>
<button
class=
"btn btn-info"
>
活动文章
</button>
<button
class=
"btn btn-primary"
>
编辑
</button>
<button
class=
"btn btn-danger btn-delete"
data-id=
"
{{
id
}}
"
>
删除
</button>
<td
class=
""
>
{{
title
}}
</td>
<td
class=
""
>
{{
startTime
}}
</td>
<td
class=
""
>
{{
endTime
}}
</td>
<td
class=
""
>
{{
createTime
}}
</td>
<td
class=
""
>
<a
class=
"btn btn-info"
href=
"/admin/activity/article?actId=
{{
id
}}
"
>
活动文章
</a>
<button
class=
"btn btn-danger btn-delete"
data-id=
"
{{
id
}}
"
>
删除活动
</button>
</td>
</tr>
{{/
each
}}
...
...
apps/admin/views/action/activity/user-list.hbs
0 → 100644
View file @
95b510d
<!-- page content -->
<div
class=
"right_col"
role=
"main"
>
<div
class=
""
>
<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"
>
<thead>
<tr
class=
"headings"
>
<th
class=
"column-title"
>
活动名称
</th>
<th
class=
"column-title"
>
开始时间
</th>
<th
class=
"column-title"
>
结束时间
</th>
<th
class=
"column-title"
>
创建时间
</th>
<th
class=
"column-title"
>
活动状态
</th>
<th
class=
"column-title"
>
操作
</th>
</tr>
</thead>
<tbody>
{{#
each
activityList
}}
<tr
class=
"even pointer"
>
<td
class=
" "
>
{{
title
}}
</td>
<td
class=
" "
>
{{
startTime
}}
</td>
<td
class=
" "
>
{{
endTime
}}
</td>
<td
class=
" "
>
{{
createTime
}}
</td>
<td
class=
" "
>
未开始
</td>
<td
class=
" "
>
<button
class=
"btn btn-info"
>
活动文章
</button>
<button
class=
"btn btn-success"
>
用户统计
</button>
<button
class=
"btn btn-primary"
>
编辑
</button>
<button
class=
"btn btn-danger btn-delete"
data-id=
"
{{
id
}}
"
>
删除
</button>
</td>
</tr>
{{/
each
}}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /page content -->
...
...
public/js/admin/activity.page.js
View file @
95b510d
...
...
@@ -62,17 +62,37 @@ function bind_delete_act() {
}
})
.
then
(()
=>
{
location
.
href
=
'/admin/activity/list'
;
location
.
reload
()
;
});
};
$
(
'.btn-delete'
).
on
(
'click'
,
deleteFn
);
}
function
bind_delete_article
()
{
const
deleteFn
=
function
()
{
const
id
=
$
(
this
).
data
(
'id'
);
$
.
ajax
({
method
:
'post'
,
url
:
'/admin/api/activity/deleteArticle'
,
data
:
{
id
}
})
.
then
(()
=>
{
location
.
reload
();
});
};
$
(
'.btn-delete-article'
).
on
(
'click'
,
deleteFn
);
}
(
function
()
{
bind_date_picker
();
bind_create_act
();
bind_delete_act
();
bind_delete_article
();
}());
...
...
Please
register
or
login
to post a comment