Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pisns-forum-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
scrmGroup
pisns-forum-api
Commits
415871c8
Commit
415871c8
authored
Nov 16, 2015
by
陈志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
评论信息导出
parent
ab202691
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
51 deletions
+52
-51
forumThread.js
app/controllers/admin/forumThread.js
+50
-49
forumCommentService.js
app/service/forumCommentService.js
+2
-2
No files found.
app/controllers/admin/forumThread.js
View file @
415871c8
...
...
@@ -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
_c
omment
.
to
){
to
=
sub_comment
.
to
.
nickName
||
'游客'
;
if
(
sub
C
omment
.
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
);
};
}
};
...
...
app/service/forumCommentService.js
View file @
415871c8
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment