Commit 415871c8 authored by 陈志良's avatar 陈志良

评论信息导出

parent ab202691
......@@ -1127,26 +1127,7 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
conditions.level = '1';
conditions.floor = floor;
forumCommentService.getAllComment(conditions, 1, 1, function(err, results) {
if (err) {
cont2(err);
} else {
var asyncTasks = [];
if (results.items && results.items[0] && results.items[0].comments.length > 0) {
var items = [results.items[0]];
_.forEach(results.items[0].comments, function(e) {
var subComment = e.toObject();
subComment.floor = results.items[0].floor;
if (content) {
if (subComment.content.indexOf(content) != -1) {
items.push(subComment);
}
} else {
items.push(subComment);
}
});
cont2(null,items);
}
}
cont2(err,results?results.items:[]);
});
}else{
conditions.level = '1';
......@@ -1211,6 +1192,7 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
{caption:'发布时间', type:'string'},
{caption:'发帖人', type:'string'},
{caption:'openId', type:'string'},
{caption:'会员编号', type:'string'},
{caption:'内容', type:'string'},
{caption:'评论数', type:'string'},
{caption:'转发数', type:'string'},
......@@ -1230,10 +1212,10 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
var t_title = thread.title == '发话题'?'无标题':thread.title,
t_time = date_format(thread.created),
t_from = contentReplace(thread.from?thread.from.nickName:'游客'),
t_from_openId = thread.from?thread.from.uid:'',
t_from_openId = thread.from?thread.from.uid:'暂无',
t_praiseNames = contentReplace(thread.praiseNames),
t_praiseOpenIds = thread.praiseOpenIds;
t_praiseOpenIds = thread.praiseOpenIds,
t_from_mid = thread.from?thread.from.mid:'暂无';
rows.push([
......@@ -1241,56 +1223,75 @@ router.get('/thread/:tid/exportComments', function(req, res, next) {
t_time,
t_from,
t_from_openId,
t_from_mid,
contentReplace(thread.content),
thread.comment_count.toString(),
thread.share_count.toString(),
thread.praise_count.toString(),
t_praiseNames,
t_praiseOpenIds]);
rows.push(['','','','','','','','','','']);
rows.push(['','','','','','','','','','','']);
rows.push(['楼层','发布时间','openId','会员名','会员编号','内容','点赞数','点赞人','点赞人openId',null,null]);
console.log(items);
for (var i = items.length - 1; i >= 0; i--) {
var comment = items[i];
var thisFloor = comment.floor || '互动',
time = date_format(comment.created),
openId = '',
nickName = '',
fromMid = '',
content = comment.content?contentReplace(comment.content) : '',
openId = '暂无',
nickName = '暂无',
fromMid = '暂无',
content = comment.content?contentReplace(comment.content) : '暂无',
praiseCount = comment.praiseCount || 0,
praiseNames = '',
praiseOpenIds = '';
praiseNames = '暂无',
praiseOpenIds = '暂无';
if(comment.praiseNames){
praiseNames = comment.praiseNames.toString();
praiseOpenIds = comment.praiseOpenIds.toString();
}
if(comment.from){
openId = comment.from.uid || '';
openId = comment.from.uid || '暂无';
nickName = comment.from.displayName || comment.from.nickName || '游客';
fromMid = comment.from.mid || '';
fromMid = comment.from.mid || '暂无';
}
var this_row = [thisFloor + '', time,openId, contentReplace(nickName),fromMid.toString(), content, praiseCount.toString(), praiseNames,praiseOpenIds,null,null];
var this_row = [
thisFloor + '',
time,
openId,
contentReplace(nickName),
fromMid.toString(),
content,
praiseCount.toString(),
praiseNames,
praiseOpenIds,
null,null];
rows.push(this_row);
if(!floor && !mid && comment.comments.length > 0){
if(!mid && comment.comments.length > 0){
for (var k = 0; k < comment.comments.length; k++) {
var sub_comment = comment.comments[k];
var time = date_format(sub_comment.created),
openId = '',
nickName = '',
content = sub_comment.content?contentReplace(sub_comment.content) : '',
to = '';
if(sub_comment.from){
openId = sub_comment.from.uid || '';
nickName = sub_comment.from.nickName || '游客';
var subComment = comment.comments[k];
var subTime = date_format(subComment.created),
subOpenId = '暂无',
subMid = '暂无',
subNickName = '暂无',
subContent = subComment.content?contentReplace(subComment.content) : '暂无',
subTo = '暂无';
if(subComment.from){
subOpenId = subComment.from.uid || '暂无';
subNickName = subComment.from.nickName || '游客';
subMid = subComment.from.mid || '暂无';
}
if(sub_comment.to){
to = sub_comment.to.nickName || '游客';
if(subComment.to){
subTo = contentReplace(subComment.to.nickName) || '游客';
}
var this_row = [nickName + ' 回复 ' + to, time,openId, nickName, content, '0', null,null,null,null];
rows.push(this_row);
var subRow = [
subNickName + ' 回复 ' + subTo,
subTime,
subOpenId,
nickName,
subMid.toString(),
content,
'0',
null,null,null,null];
rows.push(subRow);
};
}
};
......
......@@ -181,7 +181,7 @@ function populateComment(doc, callback) {
status: 1
}).populate({
path: 'from to',
select: 'uid nickName icon'
select: 'uid nickName icon mid'
}).exec(function(err, c) {
if (err) {
console.error(err);
......@@ -536,7 +536,7 @@ exports.getAllCommentByThread = function(conditions, callback) {
select: 'from'
}).populate({
path: 'from to',
select: '_id uid nickName icon'
select: '_id uid nickName icon mid'
}).sort('-created').exec(function(err, docs) {
if (err) {
console.error(err);
......
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