...
|
...
|
@@ -7,7 +7,9 @@ const ArticleModel = require('../models/article'); |
|
|
|
|
|
const ADD_ARTICLE_SUCCESS = '文章发表成功';
|
|
|
const GET_ARTICLES_SUCCESS = '获取文章列表成功';
|
|
|
const INVALID_IMG_OR_CONTENT = '图片和内容都不能为空';
|
|
|
const INVALID_ACTIVITY_ID = '活动ID[actId]不能为空';
|
|
|
const INVALID_IMG = '图片[imgUrl]不能为空';
|
|
|
const INVALID_CONTENT = '内容[content]都不能为空';
|
|
|
|
|
|
const article = {
|
|
|
/**
|
...
|
...
|
@@ -33,17 +35,24 @@ const article = { |
|
|
* @param res
|
|
|
*/
|
|
|
publish(req, res) {
|
|
|
let errorMsg = '';
|
|
|
const actId = req.body.actId;
|
|
|
const imgUrl = req.body.imgUrl;
|
|
|
const content = req.body.content;
|
|
|
|
|
|
if (!imgUrl || !content) {
|
|
|
!imgUrl && (errorMsg = INVALID_IMG);
|
|
|
!content && (errorMsg = INVALID_CONTENT);
|
|
|
!actId && (errorMsg = INVALID_ACTIVITY_ID);
|
|
|
|
|
|
if (errorMsg) {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
message: INVALID_IMG_OR_CONTENT
|
|
|
message: errorMsg
|
|
|
});
|
|
|
}
|
|
|
|
|
|
const params = {
|
|
|
actId,
|
|
|
imgUrl,
|
|
|
content
|
|
|
};
|
...
|
...
|
|