Commit 5f6d3c8e authored by 陈志良's avatar 陈志良

Merge branch 'Gabriel_0831' into SANDBOX

Conflicts:
	app/service/forumThreadService.js
parents 55018dfb 13e85e0e
...@@ -567,7 +567,7 @@ router.get('/info/myAttend', function(req, res, next) { ...@@ -567,7 +567,7 @@ router.get('/info/myAttend', function(req, res, next) {
}); });
cont(null,threadIds); cont(null,threadIds);
}else{ }else{
res.json(_.assign({data:[],total:0}, returnCode.SUCCESS)); res.json(_.assign({items:[],total:0}, returnCode.SUCCESS));
} }
} }
}); });
......
...@@ -32,6 +32,8 @@ function create(req, callback) { ...@@ -32,6 +32,8 @@ function create(req, callback) {
entity.pid = null; entity.pid = null;
} }
var address = entity.address || null; var address = entity.address || null;
if (address) { if (address) {
entity.address = JSON.parse(address); entity.address = JSON.parse(address);
...@@ -54,15 +56,39 @@ function create(req, callback) { ...@@ -54,15 +56,39 @@ function create(req, callback) {
entity.images = array; entity.images = array;
} }
//-----------处理前端上传图片结束 //-----------处理前端上传图片结束
if(entity.pid && entity.type == 3 ){
forumThreadService.createThread(entity, function(err, entity) { forumThreadService.getByConditions({type:3,level:'2',pid:entity.pid,from:entity.from},function(err,doc){
if (err) { if(doc){
console.error(err); var update = {
callback(err, null); $set:{
} else { images:entity.images,
callback(null, entity); content:entity.content
} }
}); };
forumThreadService.updateThreadById(doc._id,update,function(err,updatedDoc){
callback(err,entity);
});
}else{
forumThreadService.createThread(entity, function(err, entity) {
if (err) {
console.error(err);
callback(err, null);
} else {
callback(null, entity);
}
});
}
});
}else{
forumThreadService.createThread(entity, function(err, entity) {
if (err) {
console.error(err);
callback(err, null);
} else {
callback(null, entity);
}
});
}
} }
//根据发帖者分页查询话题列表 //根据发帖者分页查询话题列表
...@@ -235,6 +261,26 @@ router.get('/thread/:tid/get', function(req, res, next) { ...@@ -235,6 +261,26 @@ router.get('/thread/:tid/get', function(req, res, next) {
} }
}); });
//获取目标论坛文章
router.get('/thread/photo/:pid/get', function(req, res, next) {
var pid = req.params.pid || null,
userId = req.session.mobileForumUser.userId;;
if (pid) {
forumThreadService.getByConditions({type:3,level:'2',pid:pid,from:userId},function(err,thread){
if (err) {
console.error(err);
res.json(returnCode.BUSY);
} else {
var rs = {};
rs.data = thread;
res.json(_.assign(rs, returnCode.SUCCESS));
}
});
} else {
res.json(returnCode.WRONG_PARAM);
}
});
//更新文章状态、如:屏蔽 //更新文章状态、如:屏蔽
router.post('/thread/:tid/update', function(req, res, next) { router.post('/thread/:tid/update', function(req, res, next) {
var tid = req.params.tid; var tid = req.params.tid;
...@@ -1339,4 +1385,3 @@ router.post('/thread/:tid/disable', function(req, res, next) { ...@@ -1339,4 +1385,3 @@ router.post('/thread/:tid/disable', function(req, res, next) {
res.json(returnCode.WRONG_PARAM); res.json(returnCode.WRONG_PARAM);
} }
}); });
...@@ -122,7 +122,17 @@ exports.getById = function(id, callback) { ...@@ -122,7 +122,17 @@ exports.getById = function(id, callback) {
} }
}); });
} }
//根据ID获取文章记录,不查评论,子话题
exports.getByConditions = function(conditions, callback) {
ForumThread.findOne(conditions, function(err, result) {
if (err) {
console.error(err);
callback(err, null);
} else {
callback(null, result);
}
});
}
//根据ID获取文章 //根据ID获取文章
exports.getThreadById = function(tid, callback) { exports.getThreadById = function(tid, callback) {
async.parallel([ async.parallel([
...@@ -145,7 +155,7 @@ exports.getThreadById = function(tid, callback) { ...@@ -145,7 +155,7 @@ exports.getThreadById = function(tid, callback) {
level: '1' level: '1'
// status:1 // status:1
}; };
//获取最新10条评论 //获取最新10条评论
forumCommentService.getAllComment(conditions, 1, 10, function(err, results) { forumCommentService.getAllComment(conditions, 1, 10, function(err, results) {
if (err) { if (err) {
console.log(err); console.log(err);
...@@ -178,7 +188,7 @@ exports.getThreadById = function(tid, callback) { ...@@ -178,7 +188,7 @@ exports.getThreadById = function(tid, callback) {
pid: tid, pid: tid,
type: 3, type: 3,
status:1, status:1,
images: {$exists: true, $not: {$size: 0}} images: {$exists: true, $not: {$size: 0}}
}; };
getAllThreadByFidHelp(conditions, 1, 10, '-created', function(err, threads) { getAllThreadByFidHelp(conditions, 1, 10, '-created', function(err, threads) {
if (err) { if (err) {
...@@ -195,7 +205,7 @@ exports.getThreadById = function(tid, callback) { ...@@ -195,7 +205,7 @@ exports.getThreadById = function(tid, callback) {
pid: tid, pid: tid,
type: 3, type: 3,
status:1, status:1,
images: {$exists: true, $not: {$size: 0}} images: {$exists: true, $not: {$size: 0}}
}; };
getAllThreadByFidHelp(conditions, 1, 10, '-praise_count', function(err, threads) { getAllThreadByFidHelp(conditions, 1, 10, '-praise_count', function(err, threads) {
if (err) { if (err) {
...@@ -273,7 +283,7 @@ exports.getThreadByIdNoLimit = function(tid, callback) { ...@@ -273,7 +283,7 @@ exports.getThreadByIdNoLimit = function(tid, callback) {
level: '1' level: '1'
// status:1 // status:1
}; };
//获取最新10条评论 //获取最新10条评论
forumCommentService.getAllComment(conditions, 1, 999, function(err, results) { forumCommentService.getAllComment(conditions, 1, 999, function(err, results) {
if (err) { if (err) {
console.log(err); console.log(err);
...@@ -306,7 +316,7 @@ exports.getThreadByIdNoLimit = function(tid, callback) { ...@@ -306,7 +316,7 @@ exports.getThreadByIdNoLimit = function(tid, callback) {
pid: tid, pid: tid,
type: 3, type: 3,
status:1, status:1,
images: {$exists: true, $not: {$size: 0}} images: {$exists: true, $not: {$size: 0}}
}; };
getAllThreadByFidHelp(conditions, 1, 10, '-created', function(err, threads) { getAllThreadByFidHelp(conditions, 1, 10, '-created', function(err, threads) {
if (err) { if (err) {
...@@ -323,7 +333,7 @@ exports.getThreadByIdNoLimit = function(tid, callback) { ...@@ -323,7 +333,7 @@ exports.getThreadByIdNoLimit = function(tid, callback) {
pid: tid, pid: tid,
type: 3, type: 3,
status:1, status:1,
images: {$exists: true, $not: {$size: 0}} images: {$exists: true, $not: {$size: 0}}
}; };
getAllThreadByFidHelp(conditions, 1, 10, '-praise_count', function(err, threads) { getAllThreadByFidHelp(conditions, 1, 10, '-praise_count', function(err, threads) {
if (err) { if (err) {
...@@ -632,7 +642,7 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) { ...@@ -632,7 +642,7 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
path: 'comments', path: 'comments',
options: { options: {
where:{status:1}, where:{status:1},
limit: 3, limit: 5,
sort: '-created' sort: '-created'
}, },
select: 'from to created content level' select: 'from to created content level'
...@@ -910,7 +920,7 @@ exports.updateThreadCommentCountInc = function(threadId, callback) { ...@@ -910,7 +920,7 @@ exports.updateThreadCommentCountInc = function(threadId, callback) {
}); });
}; };
//更新文章评论数 //更新文章评论数
exports.updateThreadCommentCount = function(threadId, callback) { exports.updateThreadCommentCount = function(threadId, callback) {
ForumThread.update({ ForumThread.update({
_id: threadId _id: threadId
...@@ -995,7 +1005,7 @@ function getAllThreadByFidHelpAndNickName(user_ids, conditions, pageNo, pageSize ...@@ -995,7 +1005,7 @@ function getAllThreadByFidHelpAndNickName(user_ids, conditions, pageNo, pageSize
path: 'comments', path: 'comments',
options: { options: {
where:{status:1}, where:{status:1},
limit: 3, limit: 5,
sort: '-created' sort: '-created'
}, },
select: 'from to created content' select: 'from to created content'
...@@ -1031,6 +1041,7 @@ exports.getAllThreadByFidAndNickName = function(nickName, conditions, pageNo, pa ...@@ -1031,6 +1041,7 @@ exports.getAllThreadByFidAndNickName = function(nickName, conditions, pageNo, pa
} }
getAllThreadByFidHelpAndNickName(user_ids, conditions, pageNo, pageSize, sort, callback); getAllThreadByFidHelpAndNickName(user_ids, conditions, pageNo, pageSize, sort, callback);
} }
}); });
} }
//获取某个文章
...@@ -67,7 +67,7 @@ var config = { ...@@ -67,7 +67,7 @@ var config = {
app: { app: {
name: 'pisns-forum-api' name: 'pisns-forum-api'
}, },
service:'http://pisns.wxpai.cn', service:'http://piplus.wxpai.cn',
port: 3011, port: 3011,
mongodb: { mongodb: {
...@@ -86,9 +86,9 @@ var config = { ...@@ -86,9 +86,9 @@ var config = {
devCDNURL: 'http://dev.fs.wxpai.cn/' devCDNURL: 'http://dev.fs.wxpai.cn/'
}, },
sessionStore: { sessionStore: {
password: 'future123456', password: 'a39131f8d598429f:GuangZhouhdp123',
port: 6379, port: 6379,
host: '10.168.27.179', host: 'a39131f8d598429f.m.cnhza.kvstore.aliyuncs.com',
db: 2 db: 2
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment