Commit 63b57f88 authored by strong's avatar strong

Merge commit '9f297526'

parents 7b7da019 9f297526
......@@ -89,6 +89,22 @@ function mapReduce(model, match, group, date, callback) {
});
}
//统计数量
function count(model, match, date, callback) {
model.count(match, function(err, count) {
if (err) {
console.error(err);
callback(err, null);
} else {
var data = {
date: date,
count: count
};
callback(null, data);
}
});
}
//统计
function countSex(t_id, sex, callback) {
......@@ -366,15 +382,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
}
}
};
var group = {
_id: {
_id: '$_id'
},
count: {
$sum: 1
}
};
mapReduce(ForumUserThreadControl, match, group, d, cont);
count(ForumUserThreadControl, match, d, cont);
});
});
......@@ -390,15 +398,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
$lte: new Date(d + ' 23:59:59')
}
};
var group = {
_id: {
_id: '$_id'
},
count: {
$sum: 1
}
};
mapReduce(ForumPraiseLog, match, group, d, cont);
count(ForumPraiseLog, match, d, cont);
});
});
......@@ -414,15 +414,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
$lte: new Date(d + ' 23:59:59')
}
};
var group = {
_id: {
_id: '$_id'
},
count: {
$sum: 1
}
};
mapReduce(ForumComment, match, group, d, cont);
count(ForumComment, match, d, cont);
});
});
......@@ -438,15 +430,7 @@ router.post('/getThreadActionStatistic', function(req, res, next) {
$lte: new Date(d + ' 23:59:59')
}
};
var group = {
_id: {
_id: '$_id'
},
count: {
$sum: 1
}
};
mapReduce(ForumShareLog, match, group, d, cont);
count(ForumShareLog, match, d, cont);
});
});
......
......@@ -282,7 +282,7 @@ function getWXV2(res, title, desc, link, imgUrl, mid,ent_code, id,type,forumThre
ent_code:ent_code
});
}
//微信分享接口V3
//微信分享接口V2
router.get('/sharev2.js', function(req, res, next) {
var rs = {},
type = req.query.type,
......@@ -292,7 +292,9 @@ router.get('/sharev2.js', function(req, res, next) {
mid = req.session.openUser.mid,
link = '/app/forum/' + ent_code + '/v2?pageUrl=',
share_log = {};
delete req.session.mobileForumUser.share_log;
// delete req.session.mobileForumUser.share_log; //在接口分享中不再使用这个,因为在其它地方会把req.session.mobileForumUser重新赋值
delete req.session.shareLog; //新的分享对象
var title = '',desc = '',imgUrl = '';
......@@ -304,6 +306,8 @@ router.get('/sharev2.js', function(req, res, next) {
//分享记录对象
share_log.type = 2;
share_log.info = id;
//替换分享log内容
req.session.shareLog = share_log;
forumInfoService.getInfoById(id, function(err, forumInfo) {
if (err) {
......@@ -322,8 +326,6 @@ router.get('/sharev2.js', function(req, res, next) {
});
}else if (type === 'Thread') {
share_log.type = 3;
share_log.thread = id;
then(function(cont) {
//获得文章
forumThreadService.getThreadByIdSimple({_id:id},cont);
......@@ -332,9 +334,15 @@ router.get('/sharev2.js', function(req, res, next) {
//文章不存在
cont('分享文章不存在');
}else{
share_log.type = 3;
share_log.thread = id;
share_log.p_thread = thread.pid;
share_log.info = thread.info._id || thread.info;
share_log.thread_type = thread.pid?4:thread.type;
//替换分享log内容
req.session.shareLog = share_log;
//组装分享路径与判断分享类型
var baseParamsUrl = '&infoId=' + thread.info._id + '&ent_code=' + ent_code + '&tId=' + thread._id +'&uId='+uId;
var share_type = '';
......@@ -392,146 +400,4 @@ router.get('/sharev2.js', function(req, res, next) {
res.json(_.assign({result:false},returnCode.WRONG_PARAM));
});
}
req.session.mobileForumUser.share_log = share_log;
});
//微信分享接口V2
// router.get('/sharev2.js', function(req, res, next) {
// var rs = {},
// type = req.query.type,
// id = req.query.id,
// uId= req.session.mobileForumUser.userId,
// ent_code = req.session.user.ent_code,
// mid = 0,
// link = '/app/forum/' + ent_code + '/v2?pageUrl=',
// share_log = {};
// if (req.session.openUser && req.session.openUser.mid) {
// mid = req.session.openUser.mid;
// }
// delete req.session.mobileForumUser.share_log;
// //板块微信接口
// if(!type || !id){
// console.error('请求参数错误')
// res.json(_.assign({result:false},returnCode.WRONG_PARAM));
// }else if (type === 'Info') {
// //分享记录对象
// share_log.type = 2;
// share_log.info = id;
// forumInfoService.getInfoById(id, function(err, forumInfo) {
// if (err) {
// console.error(err);
// res.json(_.assign({result:false},returnCode.BUSY));
// return;
// }
// if(forumInfo.share_type == 1){
// var shareInfo = forumInfo.share || {};
// var title = shareInfo.title || '',
// desc = shareInfo.description || '',
// imgUrl = shareInfo.icon || '';
// link = link + 'index&infoId='+ id+'&uId='+uId;
// getWXV2(res, title, desc, link, imgUrl, mid,ent_code, id,type,null);
// return;
// }else{
// //默认分享设置 //查询板块默认分享设置
// forumShareConfigService.getByKey(ent_code, 'share', function(err, result) {
// if(err){
// console.error(err);
// res.json(_.assign({result:false},returnCode.BUSY));
// }else{
// var title = '',desc = '',imgUrl = '';
// if (result) {
// //匹配板块默认分享设置
// result = result.meta_value;
// _.forEach(result,function(e){
// if (e.type === 'info') {
// title = e.title;
// desc = e.desc;
// imgUrl = e.imgUrl;
// return;
// }
// });
// link = link + 'index&infoId='+ id+'&uId='+uId;
// getWXV2(res, title, desc, link, imgUrl, mid,ent_code, id,type,null);
// }else{
// //没找到板块默认分享设置
// console.error('info默认分享设置不存在');
// res.json(_.assign({result:false},returnCode.DATA_NOTEXITS));
// }
// }
// });
// }
// });
// }else if (type === 'Thread') {
// share_log.type = 3;
// share_log.thread = id;
// then(function(cont) {
// //获得文章
// forumThreadService.getById(id,cont);
// }).then(function(cont, thread) {
// if(!thread){
// //文章不存在
// cont('分享文章不存在');
// }else{
// share_log.p_thread = thread.pid;
// share_log.info = thread.info;
// share_log.thread_type = thread.pid?4:thread.type;
// //组装分享路径与判断分享类型
// //判断分享类型 1、文章 2、话题 3、照片墙
// var share_type = '';
// if (thread.type === 1 ) {
// link = link + 'detail&infoId=' + thread.info + '&ent_code=' + ent_code + '&tId=' + thread._id;
// share_type = 'article';
// }else if(thread.type === 2 && thread.level === 2){
// link = link + 'photoDetail&infoId=' + thread.info + '&ent_code=' + ent_code + '&tId=' + thread._id;
// share_type = 'photo';
// }else if (thread.type === 2 && thread.level === 1) {
// link = link + 'topic&infoId=' + thread.info + '&ent_code=' + ent_code + '&tId=' + thread._id;
// share_type = 'topic';
// } else if (thread.type === 3) {
// link = link + 'photoWall&infoId=' + thread.info + '&ent_code=' + ent_code + '&tId=' + thread._id;
// share_type = 'photo';
// }
// link = link +'&uId='+uId;
// //获取分享设置
// if (!thread.share || thread.share_type==1) {
// //获取默认文章分享设置
// forumShareConfigService.getByKey(ent_code, 'share', function(err, sc) {
// var title = '',desc = '',imgUrl = '';
// if(err || !sc){
// cont(err || share_type+'默认分享设置不存在');
// }else{
// sc = sc.meta_value;
// //设置分享信息
// _.forEach(sc,function(e){
// if(share_type === e.type){
// title = e.title;
// desc = e.desc;
// imgUrl = e.imgUrl;
// return;
// }
// });
// getWXV2(res, title, desc, link, imgUrl, mid,ent_code,thread._id,type,thread);
// }
// });
// } else {
// //获取个性化文章分享设置
// forumShareService.getById(thread.share, function(err, forumShare) {
// if(err || !forumShare){
// //文章个性化分享设置不存在
// console.error(err || '文章个性化分享设置不存在');
// res.json(_.assign({result:false},returnCode.DATA_NOTEXITS));
// }else{
// getWXV2(res, forumShare.title, forumShare.description, link, forumShare.icon, mid,ent_code,thread._id,type,thread);
// }
// });
// }
// }
// }).fail(function(cont, err) {
// console.error(err);
// res.json(_.assign({result:false},returnCode.WRONG_PARAM));
// });
// }
// req.session.mobileForumUser.share_log = share_log;
// });
\ No newline at end of file
});
\ No newline at end of file
......@@ -14,7 +14,6 @@ var forumPraiseLogService = require('../../service/forumPraiseLogService');
var forumShareLogService = require('../../service/forumShareLogService');
var forumCommentService = require('../../service/forumCommentService');
var forumUserThreadControlService = require('../../service/forumUserThreadControlService');
// var forumLimitActionRefService = require('../../service/forumLimitActionRefService');
var forumLimitOperationService = require('../../service/forumLimitOperationService');
var forumThreadAttendService = require('../../service/forumThreadAttendService');
var commentTips = require('../../utils/commentTips');
......@@ -673,440 +672,6 @@ router.post('/thread/:tid/delete', function(req, res, next) {
}
});
// //文章点赞
// router.post('/thread/:tid/raise', function(req, res, next) {
// var userId = req.session.mobileForumUser.userId;
// var mid = req.session.openUser.mid;
// var tid = req.params.tid || null;
// var ent_code = req.session.user.ent_code;
// if (tid) {
// var integral = req.session.openUser.integral || 0;
// var exp = req.session.openUser.exp || 0;
// //判断是否已经点赞
// forumPraiseLogService.queryPraiseLog(tid, null, user.getMobileUser(req), 1, function(err, doc) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// //1.检查是否有权限
// forumRolePermissionService.checkRolePermiss(ent_code, 'raise', integral, exp, function(err, result) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// if (result) { //有操作权限
// //2.获取论坛文章
// forumThreadService.getThreadById(tid, function(err, thread) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// async.parallel([
// function(callback) {
// //3.更新文章统计数据(点赞数)
// if (thread) {
// forumThreadService.updateThreadRaiseCount(tid, function(err, cb) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// } else {
// callback('cannot find thread by id', null);
// }
// },
// function(callback) {
// if (doc) { //如果已存在,更新为点赞日志
// forumPraiseLogService.updatePraiseLog(doc._id, 0, function(err, result) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// } else { //不存在,创建点赞日志
// var entity = {
// ent_code: ent_code,
// user: user.getMobileUser(req),
// thread: tid,
// ip: req.ip,
// comment: null,
// type: 1,
// status: 0
// };
// //4.创建点赞日志
// forumPraiseLogService.createPraiseLog(entity, function(err, result) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// }
// }
// ], function(err, results) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// // forumLimitOperationService.checkLimitOperationProhibitionAddIntegral(userId, function(err, flag){
// // if(err){
// // console.error(err);
// // }else{
// // if(!flag){
// // httpService.sendRequest(ent_code, req.session.openUser.mid, 'thread_praise');
// // }
// // }
// // });
// //更新点赞redis
// redisPraiseLog.get(ent_code, userId, 'thread', function(error, docs) {
// var list = docs;
// list.push(tid);
// redisPraiseLog.set(ent_code, userId, 'thread', list, function() {});
// });
// forumThreadService.getThreadById(tid, function(err, doc) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// var rs = {};
// rs.praise_count = doc.praise_count;
// res.json(_.assign(rs, returnCode.SUCCESS));
// }
// });
// }
// });
// }
// });
// } else {
// res.json(returnCode.ACTION_NOT_PERMISSION);
// }
// }
// });
// }
// });
// } else {
// res.json(returnCode.WRONG_PARAM);
// }
// });
// //文章取消点赞
// router.post('/thread/:tid/cancelRaise', function(req, res, next) {
// var userId = req.session.mobileForumUser.userId;
// var mid = req.session.openUser.mid;
// var tid = req.params.tid || null;
// var ent_code = req.session.user.ent_code;
// if (tid) {
// var integral = req.session.openUser.integral || 0;
// var exp = req.session.openUser.exp || 0;
// //判断是否已经点赞
// forumPraiseLogService.queryPraiseLog(tid, null, userId, 1, function(err, doc) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// if (doc) {
// var praiseId = doc._id;
// //1.检查是否有权限
// forumRolePermissionService.checkRolePermiss(ent_code, 'raise', integral, exp, function(err, result) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// if (result) { //有操作权限
// //2.获取论坛文章
// forumThreadService.getThreadById(tid, function(err, thread) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// async.parallel([
// function(callback) {
// //3.更新文章统计数据(点赞数)
// if (thread && thread.praise_count > 0) {
// forumThreadService.updateThreadRaiseCountDec(tid, function(err, cb) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// } else {
// callback('cannot find thread by id', null);
// }
// },
// function(callback) {
// //4.更新点赞日志
// forumPraiseLogService.updatePraiseLog(praiseId, 1, function(err, result) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// }
// ], function(err, results) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// //更新点赞redis
// redisPraiseLog.get(ent_code, userId, 'thread', function(error, docs) {
// var list = docs;
// for (var i = 0; i < list.length; i++) {
// if (list[i].toString() == tid) {
// list.splice(i, 1);
// break;
// }
// }
// redisPraiseLog.set(ent_code, userId, 'thread', list, function() {});
// });
// forumThreadService.getThreadById(tid, function(err, doc) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// var rs = {};
// rs.praise_count = doc.praise_count;
// res.json(_.assign(rs, returnCode.SUCCESS));
// }
// });
// }
// });
// }
// });
// } else {
// res.json(returnCode.ACTION_NOT_PERMISSION);
// }
// }
// });
// }
// }
// });
// } else {
// res.json(returnCode.WRONG_PARAM);
// }
// });
//文章点赞
// router.post('/thread/:tid/raise', function(req, res, next) {
// var userId = req.session.mobileForumUser.userId;
// var mid = req.session.openUser.mid;
// var tid = req.params.tid || null;
// var ent_code = req.session.user.ent_code;
// if (tid) {
// var integral = req.session.openUser.integral || 0;
// var exp = req.session.openUser.exp || 0;
// //判断是否已经点赞
// forumPraiseLogService.queryPraiseLog(tid, null, user.getMobileUser(req), 1, function(err, doc) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// //1.检查是否有权限
// forumRolePermissionService.checkRolePermiss(ent_code, 'raise', integral, exp, function(err, result) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// if (result) { //有操作权限
// //2.获取论坛文章
// forumThreadService.getThreadById(tid, function(err, thread) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// async.parallel([
// function(callback) {
// //3.更新文章统计数据(点赞数)
// if (thread) {
// forumThreadService.updateThreadRaiseCount(tid, function(err, cb) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// } else {
// callback('cannot find thread by id', null);
// }
// },
// function(callback) {
// if (doc) { //如果已存在,更新为点赞日志
// forumPraiseLogService.updatePraiseLog(doc._id, 0, function(err, result) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// } else { //不存在,创建点赞日志
// var entity = {
// ent_code: ent_code,
// user: user.getMobileUser(req),
// thread: tid,
// ip: req.ip,
// comment: null,
// type: 1,
// status: 0
// };
// //4.创建点赞日志
// forumPraiseLogService.createPraiseLog(entity, function(err, result) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// }
// }
// ], function(err, results) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// // forumLimitOperationService.checkLimitOperationProhibitionAddIntegral(userId, function(err, flag){
// // if(err){
// // console.error(err);
// // }else{
// // if(!flag){
// // httpService.sendRequest(ent_code, req.session.openUser.mid, 'thread_praise');
// // }
// // }
// // });
// //更新点赞redis
// redisPraiseLog.get(ent_code, userId, 'thread', function(error, docs) {
// var list = docs;
// list.push(tid);
// redisPraiseLog.set(ent_code, userId, 'thread', list, function() {});
// });
// forumThreadService.getThreadById(tid, function(err, doc) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// var rs = {};
// rs.praise_count = doc.praise_count;
// res.json(_.assign(rs, returnCode.SUCCESS));
// }
// });
// }
// });
// }
// });
// } else {
// res.json(returnCode.ACTION_NOT_PERMISSION);
// }
// }
// });
// }
// });
// } else {
// res.json(returnCode.WRONG_PARAM);
// }
// });
//文章取消点赞
// router.post('/thread/:tid/cancelRaise', function(req, res, next) {
// var userId = req.session.mobileForumUser.userId;
// var mid = req.session.openUser.mid;
// var tid = req.params.tid || null;
// var ent_code = req.session.user.ent_code;
// if (tid) {
// var integral = req.session.openUser.integral || 0;
// var exp = req.session.openUser.exp || 0;
// //判断是否已经点赞
// forumPraiseLogService.queryPraiseLog(tid, null, userId, 1, function(err, doc) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// if (doc) {
// var praiseId = doc._id;
// //1.检查是否有权限
// forumRolePermissionService.checkRolePermiss(ent_code, 'raise', integral, exp, function(err, result) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// if (result) { //有操作权限
// //2.获取论坛文章
// forumThreadService.getThreadById(tid, function(err, thread) {
// if (err) {
// res.json(returnCode.BUSY);
// } else {
// async.parallel([
// function(callback) {
// //3.更新文章统计数据(点赞数)
// if (thread && thread.praise_count > 0) {
// forumThreadService.updateThreadRaiseCountDec(tid, function(err, cb) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// } else {
// callback('cannot find thread by id', null);
// }
// },
// function(callback) {
// //4.更新点赞日志
// forumPraiseLogService.updatePraiseLog(praiseId, 1, function(err, result) {
// if (err) {
// callback(err, null);
// } else {
// callback(null, null);
// }
// });
// }
// ], function(err, results) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// //更新点赞redis
// redisPraiseLog.get(ent_code, userId, 'thread', function(error, docs) {
// var list = docs;
// for (var i = 0; i < list.length; i++) {
// if (list[i].toString() == tid) {
// list.splice(i, 1);
// break;
// }
// }
// redisPraiseLog.set(ent_code, userId, 'thread', list, function() {});
// });
// forumThreadService.getThreadById(tid, function(err, doc) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// var rs = {};
// rs.praise_count = doc.praise_count;
// res.json(_.assign(rs, returnCode.SUCCESS));
// }
// });
// }
// });
// }
// });
// } else {
// res.json(returnCode.ACTION_NOT_PERMISSION);
// }
// }
// });
// }
// }
// });
// } else {
// res.json(returnCode.WRONG_PARAM);
// }
// });
//文章点赞
router.post('/thread/:tid/raise', function(req, res, next) {
......
......@@ -22,7 +22,6 @@ var ForumPVLog = mongoose.model('ForumPVLog'),
ForumShareLog = mongoose.model('ForumShareLog'),
ForumThread = mongoose.model('ForumThread');
exports.sendRequest = function(ent_code, mid, action, messageid, integral, exp) {
console.log('送积分了');
var obj = {
tag: 'member',
key: 'forum',
......@@ -143,7 +142,7 @@ exports.createLog = function(req,source,info,type,thread_type,thread,p_thread) {
};
exports.createShareLog = function(req,share_type) {
var logObj = req.session.mobileForumUser.share_log || {};
var logObj = req.session.shareLog || {};
logObj.source = req.session.mobileForumUser.source;
logObj.mid = req.session.openUser.mid;
logObj.ent_code = req.session.user.ent_code;
......
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