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
8aa1e3d3
Commit
8aa1e3d3
authored
Aug 27, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1111
parent
465aa545
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
3 deletions
+54
-3
forumInfo.js
app/controllers/mobile/forumInfo.js
+1
-0
forumCommentService.js
app/service/forumCommentService.js
+53
-3
No files found.
app/controllers/mobile/forumInfo.js
View file @
8aa1e3d3
...
@@ -421,6 +421,7 @@ router.get('/info/myComments', function(req, res, next) {
...
@@ -421,6 +421,7 @@ router.get('/info/myComments', function(req, res, next) {
var
id
=
user
.
getMobileUser
(
req
);
var
id
=
user
.
getMobileUser
(
req
);
var
conditions
=
{
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
ent_code
:
req
.
session
.
user
.
ent_code
,
status
:
1
,
$or
:[{
from
:
id
},{
to
:
id
}]
$or
:[{
from
:
id
},{
to
:
id
}]
};
};
forumCommentService
.
getMyComment
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
forumCommentService
.
getMyComment
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
...
...
app/service/forumCommentService.js
View file @
8aa1e3d3
...
@@ -303,6 +303,25 @@ var countMyComment = function(conditions,callback) {
...
@@ -303,6 +303,25 @@ var countMyComment = function(conditions,callback) {
}
}
});
});
};
};
function
populateParentComment
(
doc
,
callback
){
if
(
doc
&&
doc
.
_id
&&
doc
.
level
===
2
)
{
ForumComment
.
findOne
({
comments
:
{
$elemMatch
:
doc
.
_id
},
status
:
1
}).
exec
(
function
(
err
,
c
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
null
,
null
);
}
else
{
if
(
c
){
callback
(
null
,
c
);
}
else
{
callback
(
null
);
}
}
});
}
else
{
callback
(
null
,
null
);
}
}
//我的评论
//我的评论
exports
.
getMyComment
=
function
(
conditions
,
pageNo
,
pageSize
,
callback
){
exports
.
getMyComment
=
function
(
conditions
,
pageNo
,
pageSize
,
callback
){
countMyComment
(
conditions
,
function
(
err
,
count
){
countMyComment
(
conditions
,
function
(
err
,
count
){
...
@@ -313,7 +332,10 @@ exports.getMyComment = function(conditions,pageNo,pageSize,callback){
...
@@ -313,7 +332,10 @@ exports.getMyComment = function(conditions,pageNo,pageSize,callback){
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumComment
.
find
(
conditions
)
ForumComment
.
find
(
conditions
)
.
populate
(
'thread'
).
populate
(
'from'
).
populate
(
'to'
).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
.
populate
({
path
:
'thread'
,
select
:
'_id content title type level tag'
}).
populate
({
path
:
'from to'
,
select
:
'uid nickName icon'
}).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
...
@@ -323,8 +345,36 @@ exports.getMyComment = function(conditions,pageNo,pageSize,callback){
...
@@ -323,8 +345,36 @@ exports.getMyComment = function(conditions,pageNo,pageSize,callback){
obj
.
pageNo
=
pageNo
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
docs
;
obj
.
items
=
docs
;
callback
(
null
,
obj
);
if
(
docs
&&
docs
.
length
>
0
)
{
var
asyncTasks
=
[];
docs
.
forEach
(
function
(
doc
){
asyncTasks
.
push
(
function
(
callback
)
{
populateParentComment
(
doc
,
function
(
err
,
c
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
var
newobj
=
doc
.
toObject
();
newobj
.
parent
=
c
;
delete
newobj
.
comments
;
callback
(
null
,
newobj
);
}
});
});
});
async
.
parallel
(
asyncTasks
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
callback
(
null
,
null
);
}
else
{
obj
.
items
=
results
;
callback
(
null
,
obj
);
}
});
}
else
{
callback
(
null
,
obj
);
}
}
}
});
});
}
}
...
...
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