...
|
...
|
@@ -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
|
|
|
}
|
|
|
);
|
|
|
}
|
...
|
...
|
|