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
5e10bd4a
Commit
5e10bd4a
authored
Sep 06, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
我的评论
parent
99db01d9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
3 deletions
+113
-3
forumInfo.js
app/controllers/mobile/forumInfo.js
+62
-3
forumCommentService.js
app/service/forumCommentService.js
+51
-0
No files found.
app/controllers/mobile/forumInfo.js
View file @
5e10bd4a
...
@@ -403,7 +403,7 @@ router.get('/info/myThreads', function(req, res, next) {
...
@@ -403,7 +403,7 @@ router.get('/info/myThreads', function(req, res, next) {
};
};
}
}
//获取子话题数据
//获取子话题数据
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-
created
'
,
function
(
err
,
results
)
{
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-
praise_count
'
,
function
(
err
,
results
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
...
@@ -437,6 +437,65 @@ router.get('/info/myComments', function(req, res, next) {
...
@@ -437,6 +437,65 @@ router.get('/info/myComments', function(req, res, next) {
});
});
});
});
//获取跟我相关的评论列表
router
.
get
(
'/info/:tid/comment/list'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
id
=
user
.
getMobileUser
(
req
);
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
thread
:
tid
,
//5539fa026cf87854c87be3c9
level
:
'1'
};
if
(
!
tid
){
return
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
forumCommentService
.
getAllCommentByThread
(
conditions
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
docs
=
[];
if
(
results
&&
results
.
length
>
0
){
results
.
forEach
(
function
(
doc
,
i
){
//过滤与自己无关的评论
if
(
!
doc
.
from
||
(
doc
.
from
.
_id
!==
id
&&
doc
.
thread
.
from
!==
id
)){
//文章和一级评论的作者不是自己
if
(
doc
.
comments
&&
doc
.
comments
.
length
>
0
){
//有子评论
var
comments
=
[];
doc
.
comments
.
forEach
(
function
(
comment
,
j
){
if
((
!
comment
.
from
||
comment
.
from
.
_id
!==
id
)
&&
(
!
comment
.
to
||
comment
.
to
.
_id
!==
id
)){
//二级评论的作者 和 被评论者都不是自己
console
.
log
(
'过滤二级评论===='
+
j
);
}
else
{
comments
.
push
(
comment
);
}
});
if
(
comments
.
length
>
0
){
doc
.
comments
=
comments
;
docs
.
push
(
doc
);
}
else
{
console
.
log
(
'过滤一级评论===='
+
i
);
}
}
else
{
console
.
log
(
'过滤一级评论===='
+
i
);
}
}
else
{
//文章和一级评论的作者是自己那么所有的子评论都不用过滤
docs
.
push
(
doc
);
}
});
}
var
obj
=
{};
obj
.
total
=
docs
.
length
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
docs
.
slice
((
pageNo
-
1
>=
0
?
pageNo
-
1
:
0
)
*
pageSize
,
pageSize
);
res
.
json
(
_
.
assign
(
obj
,
returnCode
.
SUCCESS
));
}
});
});
//搜索文章列表
//搜索文章列表
router
.
get
(
'/info/:fid/serachThreads'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'/info/:fid/serachThreads'
,
function
(
req
,
res
,
next
)
{
var
fid
=
req
.
params
.
fid
||
null
;
var
fid
=
req
.
params
.
fid
||
null
;
...
@@ -483,7 +542,7 @@ router.get('/info/:fid/serachThreads', function(req, res, next) {
...
@@ -483,7 +542,7 @@ router.get('/info/:fid/serachThreads', function(req, res, next) {
};
};
}
}
//获取子话题数据
//获取子话题数据
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-
created
'
,
function
(
err
,
results
)
{
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-
praise_count
'
,
function
(
err
,
results
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
...
@@ -567,7 +626,7 @@ router.get('/info/myAttend', function(req, res, next) {
...
@@ -567,7 +626,7 @@ router.get('/info/myAttend', function(req, res, next) {
});
});
cont
(
null
,
threadIds
);
cont
(
null
,
threadIds
);
}
else
{
}
else
{
res
.
json
(
_
.
assign
({
items
:[],
total
:
0
},
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
({
data
:[],
total
:
0
},
returnCode
.
SUCCESS
));
}
}
}
}
});
});
...
...
app/service/forumCommentService.js
View file @
5e10bd4a
...
@@ -392,4 +392,55 @@ exports.getMyComment = function(conditions,pageNo,pageSize,callback){
...
@@ -392,4 +392,55 @@ exports.getMyComment = function(conditions,pageNo,pageSize,callback){
});
});
}
}
});
});
};
//获取全部列表数据
exports
.
getAllCommentByThread
=
function
(
conditions
,
callback
)
{
countAll
(
conditions
,
function
(
err
,
count
){
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
ForumComment
.
find
(
conditions
).
populate
({
path
:
'thread'
,
select
:
'from'
}).
populate
({
path
:
'from to'
,
select
:
'_id uid nickName icon'
}).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
if
(
docs
&&
docs
.
length
>
0
)
{
var
asyncTasks
=
[];
docs
.
forEach
(
function
(
doc
){
asyncTasks
.
push
(
function
(
callback
)
{
populateComment
(
doc
,
function
(
err
,
c
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
var
newobj
=
doc
.
toObject
();
newobj
.
comments
=
(
c
==
null
?[]:
c
);
callback
(
null
,
newobj
);
}
});
});
});
async
.
parallel
(
asyncTasks
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
callback
(
null
,
null
);
}
else
{
callback
(
null
,
results
);
}
});
}
else
{
callback
(
null
,
null
);
}
}
});
}
});
};
};
\ No newline at end of file
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