Commit d0f77068 authored by 陈志良's avatar 陈志良

Merge branch 'Gabriel_0831'

Conflicts:
	app/service/forumThreadService.js
parents 1fccf906 13e85e0e
...@@ -44,7 +44,7 @@ var aggregate = function(model, match, group_id, sort, callback) { ...@@ -44,7 +44,7 @@ var aggregate = function(model, match, group_id, sort, callback) {
//格式化日期 (格式:年-月-日) //格式化日期 (格式:年-月-日)
function date_format(date) { function date_format(date) {
return moment(date).format('YYYY/MM/DD'); return moment(date).format('YYYYMMDD');
} }
//获取日期之间所有日期 //获取日期之间所有日期
......
...@@ -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,7 +56,30 @@ function create(req, callback) { ...@@ -54,7 +56,30 @@ function create(req, callback) {
entity.images = array; entity.images = array;
} }
//-----------处理前端上传图片结束 //-----------处理前端上传图片结束
if(entity.pid && entity.type == 3 ){
forumThreadService.getByConditions({type:3,level:'2',pid:entity.pid,from:entity.from},function(err,doc){
if(doc){
var update = {
$set:{
images:entity.images,
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) { forumThreadService.createThread(entity, function(err, entity) {
if (err) { if (err) {
console.error(err); console.error(err);
...@@ -63,6 +88,7 @@ function create(req, callback) { ...@@ -63,6 +88,7 @@ function create(req, callback) {
callback(null, entity); 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([
...@@ -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'
...@@ -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'
...@@ -1034,3 +1044,4 @@ exports.getAllThreadByFidAndNickName = function(nickName, conditions, pageNo, pa ...@@ -1034,3 +1044,4 @@ exports.getAllThreadByFidAndNickName = function(nickName, conditions, pageNo, pa
}); });
} }
//获取某个文章
...@@ -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: {
......
...@@ -60,14 +60,14 @@ module.exports = function(app, config) { ...@@ -60,14 +60,14 @@ module.exports = function(app, config) {
res.header('Access-Control-Max-Age', 7200); res.header('Access-Control-Max-Age', 7200);
next(); next();
}); });
if(app.get('env') === 'development'){
app.use(function(req, res, next) { app.use(function(req, res, next) {
if (!req.session.user ) { if (!req.session.user && req.query.key && req.query.key === 'aiwanpai') {
req.session.user = { req.session.user = {
ent_code: 100001 ent_code: 100041
}; };
} }
if (!req.session.openUser) { if (!req.session.openUser && req.query.key && req.query.key === 'aiwanpai') {
req.session.openUser = { req.session.openUser = {
openId: '1111', openId: '1111',
integral: '100', integral: '100',
...@@ -76,7 +76,6 @@ module.exports = function(app, config) { ...@@ -76,7 +76,6 @@ module.exports = function(app, config) {
} }
next(null); next(null);
}); });
}
//设置创建用户中间件 //设置创建用户中间件
app.use('/v1/forum/*',forumUser.identifyUser()); app.use('/v1/forum/*',forumUser.identifyUser());
......
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