...
|
...
|
@@ -8,6 +8,7 @@ const _ = require('lodash'); |
|
|
const mysqlCli = global.yoho.utils.mysqlCli;
|
|
|
|
|
|
const TABLE_ACT_ARTICLE = 'act_article';
|
|
|
const TABLE_ACT_ARTICLE_IMG = 'act_article_img';
|
|
|
|
|
|
class ArticleModel extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
...
|
...
|
@@ -24,21 +25,41 @@ class ArticleModel extends global.yoho.BaseModel { |
|
|
|
|
|
/**
|
|
|
* 发表文章
|
|
|
* @param content
|
|
|
* @param actId 活动ID
|
|
|
* @param content 文章内容
|
|
|
* @param imgUrl 图片链接
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
createArticle({content}) {
|
|
|
createArticle({actId, content, imgUrl}) {
|
|
|
const session = this.ctx.req.session;
|
|
|
const userId = _.get(session, 'user.id');
|
|
|
|
|
|
return mysqlCli.insert(
|
|
|
`insert into ${TABLE_ACT_ARTICLE} (user_id, content) values (:userId, :content);`,
|
|
|
`insert into ${TABLE_ACT_ARTICLE} (act_id, user_id, content) values (:actId, :userId, :content);`,
|
|
|
{
|
|
|
actId,
|
|
|
userId,
|
|
|
imgUrl,
|
|
|
content
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 文章图片插入
|
|
|
* @param articleId
|
|
|
* @param imgUrl
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
insertArticleImg(articleId, imgUrl) {
|
|
|
return mysqlCli.insert(
|
|
|
`insert into ${TABLE_ACT_ARTICLE_IMG} (article_id, img_url) values (:articleId, :imgUrl);`,
|
|
|
{
|
|
|
imgUrl,
|
|
|
articleId
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = ArticleModel;
|
...
|
...
|
|