...
|
...
|
@@ -6,6 +6,7 @@ |
|
|
|
|
|
const mysqlCli = global.yoho.utils.mysqlCli;
|
|
|
const _ = require('lodash');
|
|
|
const zerobuyModel = require('../../activity/models/zero-buy');
|
|
|
|
|
|
const TB_USER = 'user';
|
|
|
const TB_ACTIVITY = 'activity';
|
...
|
...
|
@@ -28,7 +29,7 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
*/
|
|
|
createActivity({title, startTime, endTime, repeat_limit, vote_limit}) {
|
|
|
return mysqlCli.insert(
|
|
|
`insert into ${TB_ACTIVITY} (title, start_time, end_time, repeat_limit, vote_limit)
|
|
|
`insert into ${TB_ACTIVITY} (title, start_time, end_time, repeat_limit, vote_limit)
|
|
|
values (:title, :startTime, :endTime, :repeat_limit, :vote_limit);`,
|
|
|
{
|
|
|
title,
|
...
|
...
|
@@ -46,7 +47,7 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
*/
|
|
|
activityList() {
|
|
|
return mysqlCli.query(
|
|
|
`select id, title, start_time startTime, end_time endTime, create_time createTime,
|
|
|
`select id, title, start_time startTime, end_time endTime, create_time createTime,
|
|
|
repeat_limit repeatLimit, vote_limit voteLimit from ${TB_ACTIVITY};`
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -78,12 +79,12 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
|
|
|
return mysqlCli.query(
|
|
|
`select taa.id, taai.img_url imgUrl, taa.content, taa.create_time createTime, taa.good_count goodCount,
|
|
|
taa.user_name userName, tu.user_phone phone
|
|
|
taa.user_name userName, tu.user_phone phone
|
|
|
from ${TB_ACT_ARTICLE} taa
|
|
|
left join ${TB_USER} tu
|
|
|
on taa.user_id = tu.id
|
|
|
left join ${TB_ACT_ARTICLE_IMG} taai
|
|
|
on taai.article_id = taa.id
|
|
|
on taa.user_id = tu.id
|
|
|
left join ${TB_ACT_ARTICLE_IMG} taai
|
|
|
on taai.article_id = taa.id
|
|
|
where act_id = :actId
|
|
|
${orderSql} ${limitSql};`, {
|
|
|
actId,
|
...
|
...
|
@@ -101,10 +102,10 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
exportActArticleList(actId) {
|
|
|
return mysqlCli.query(
|
|
|
`select taa.id, taa.content, taa.create_time createTime, taa.good_count goodCount,
|
|
|
tu.user_name userName, tu.user_phone phone
|
|
|
tu.user_name userName, tu.user_phone phone
|
|
|
from ${TB_ACT_ARTICLE} taa
|
|
|
left join ${TB_USER} tu
|
|
|
on taa.user_id = tu.id
|
|
|
on taa.user_id = tu.id
|
|
|
where act_id = :actId;`, {
|
|
|
actId
|
|
|
}
|
...
|
...
|
@@ -132,8 +133,8 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
*/
|
|
|
async createArticle({actId, userName, content, createTime}) {
|
|
|
return mysqlCli.insert(
|
|
|
`insert into ${TB_ACT_ARTICLE}
|
|
|
(act_id, user_name, content, create_time) values
|
|
|
`insert into ${TB_ACT_ARTICLE}
|
|
|
(act_id, user_name, content, create_time) values
|
|
|
(:actId, :userName, :content, :createTime);`,
|
|
|
{
|
|
|
actId,
|
...
|
...
|
@@ -164,10 +165,10 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
*/
|
|
|
async createY100Article(actId, articleId, headUrl, imageUrl, index, name, tag, style, career, interest, skns, desc,
|
|
|
top, createTime) {
|
|
|
let strSQL = `INSERT INTO ${TB_ACT_ARTICLE_Y100}
|
|
|
(act_id, article_id, head_url, img_url, \`index\`, name, tag, style, career, interest, skns, \`desc\`,
|
|
|
\`top\`, create_time)
|
|
|
VALUES
|
|
|
let strSQL = `INSERT INTO ${TB_ACT_ARTICLE_Y100}
|
|
|
(act_id, article_id, head_url, img_url, \`index\`, name, tag, style, career, interest, skns, \`desc\`,
|
|
|
\`top\`, create_time)
|
|
|
VALUES
|
|
|
(:actId, :articleId, :headUrl, :imageUrl, :index, :name, :tag, :style, :career, :interest, :skns, :desc,
|
|
|
:top, :createTime);`;
|
|
|
|
...
|
...
|
@@ -206,8 +207,8 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
page: _.parseInt(pageSize)
|
|
|
};
|
|
|
let sql = `
|
|
|
SELECT
|
|
|
AA.id,
|
|
|
SELECT
|
|
|
AA.id,
|
|
|
AA.good_count,
|
|
|
AA.create_time,
|
|
|
AAY.name,
|
...
|
...
|
@@ -239,7 +240,7 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
* @returns {Promise.<*>}
|
|
|
*/
|
|
|
async getY100ArticleNums(actId) {
|
|
|
let strSQL = `SELECT COUNT(*) AS total_count FROM ${TB_ACT_ARTICLE_Y100}
|
|
|
let strSQL = `SELECT COUNT(*) AS total_count FROM ${TB_ACT_ARTICLE_Y100}
|
|
|
WHERE act_id = :actId;`;
|
|
|
|
|
|
let params = {
|
...
|
...
|
@@ -258,7 +259,7 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
*/
|
|
|
createArticleImg(artId, imgUrl, createTime) {
|
|
|
return mysqlCli.insert(
|
|
|
`insert into ${TB_ACT_ARTICLE_IMG}
|
|
|
`insert into ${TB_ACT_ARTICLE_IMG}
|
|
|
(article_id, img_url, create_time) values (:artId, :imgUrl, :createTime);`,
|
|
|
{
|
|
|
artId,
|
...
|
...
|
@@ -361,6 +362,14 @@ class AdminModel extends global.yoho.BaseModel { |
|
|
}
|
|
|
);
|
|
|
}
|
|
|
|
|
|
getZerobuyList(page) {
|
|
|
return this.ctx.req.ctx(zerobuyModel).getList(-1, page, {
|
|
|
noCache: true
|
|
|
}).then(result => {
|
|
|
return result.data;
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = AdminModel;
|
...
|
...
|
|