...
|
...
|
@@ -29,7 +29,7 @@ const article = { |
|
|
if (!actId) {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
message: '活动ID[actId]不能为空'
|
|
|
message: INVALID_PARAMS
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -65,7 +65,9 @@ const article = { |
|
|
});
|
|
|
list.push(data);
|
|
|
});
|
|
|
|
|
|
return list;
|
|
|
})
|
|
|
.then(list => {
|
|
|
req.ctx(ArticleModel).allArticlesNum(actId)
|
|
|
.then(totalCount => {
|
|
|
res.json({
|
...
|
...
|
@@ -88,6 +90,7 @@ const article = { |
|
|
* @param res
|
|
|
*/
|
|
|
publish(req, res) {
|
|
|
let newId;
|
|
|
let errorMsg = '';
|
|
|
const actId = req.body.actId;
|
|
|
const imgUrl = req.body.imgUrl;
|
...
|
...
|
@@ -111,15 +114,22 @@ const article = { |
|
|
};
|
|
|
|
|
|
req.ctx(ArticleModel).createArticle(params)
|
|
|
.then((id) => {
|
|
|
req.ctx(ArticleModel).insertArticleImg(id, imgUrl)
|
|
|
.then(() => {
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
data: {id},
|
|
|
message: POST_SUCCESS
|
|
|
});
|
|
|
});
|
|
|
.then(id => {
|
|
|
newId = id;
|
|
|
return id;
|
|
|
})
|
|
|
.then(id => {
|
|
|
return req.ctx(ArticleModel)
|
|
|
.insertArticleImg(id, imgUrl);
|
|
|
})
|
|
|
.then(() => {
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
data: {
|
|
|
id: newId
|
|
|
},
|
|
|
message: POST_SUCCESS
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
|
...
|
...
|
@@ -148,7 +158,6 @@ const article = { |
|
|
.then(ret => {
|
|
|
let img_arr = _.map(ret, 'img_url');
|
|
|
|
|
|
console.log(img_arr);
|
|
|
let result = {};
|
|
|
let final_result = {};
|
|
|
|
...
|
...
|
@@ -190,13 +199,14 @@ const article = { |
|
|
|
|
|
req.ctx(ArticleModel).likeArticle(actId, articleId)
|
|
|
.then(() => {
|
|
|
req.ctx(ArticleModel).insertLikeDetail(actId, articleId)
|
|
|
.then(() => {
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
message: POST_SUCCESS
|
|
|
});
|
|
|
});
|
|
|
return req.ctx(ArticleModel)
|
|
|
.insertLikeDetail(actId, articleId);
|
|
|
})
|
|
|
.then(() => {
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
message: POST_SUCCESS
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
};
|
...
|
...
|
|