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
7ca535bb
Commit
7ca535bb
authored
Jun 01, 2016
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
搜索帖子评论增加 按指定字段排序
parent
b088abfe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
3 deletions
+90
-3
forumThreadManagement.js
app/controllers/admin/forumThreadManagement.js
+8
-3
forumCommentService.js
app/service/forumCommentService.js
+82
-0
No files found.
app/controllers/admin/forumThreadManagement.js
View file @
7ca535bb
...
...
@@ -898,7 +898,12 @@ router.get('/threadManagement/threads/:tid/comment/search', function(req, res, n
mid
=
req
.
query
.
mid
,
floor_start
=
req
.
query
.
floor_start
,
floor_end
=
req
.
query
.
floor_end
,
content
=
req
.
query
.
content
||
''
;
content
=
req
.
query
.
content
||
''
,
sortBy
=
req
.
query
.
sort
;
var
sort
=
{};
if
(
sortBy
){
sort
[
sortBy
]
=
-
1
;
}
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
thread
:
tid
,
...
...
@@ -921,7 +926,7 @@ router.get('/threadManagement/threads/:tid/comment/search', function(req, res, n
};
}
if
(
tid
&&
mid
)
{
forumCommentService
.
getCommentListByMid
(
mid
,
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
forumCommentService
.
getCommentListByMid
OrderBy
(
mid
,
conditions
,
sort
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -930,7 +935,7 @@ router.get('/threadManagement/threads/:tid/comment/search', function(req, res, n
}
});
}
else
if
(
tid
){
forumCommentService
.
getAllComment
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
forumCommentService
.
getAllComment
OrderBy
(
conditions
,
sort
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/service/forumCommentService.js
View file @
7ca535bb
...
...
@@ -192,6 +192,40 @@ exports.getAllComment = function(conditions, pageNo, pageSize, callback) {
});
};
exports
.
getAllCommentOrderBy
=
function
(
conditions
,
orderBy
,
pageNo
,
pageSize
,
callback
)
{
countAll
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sort
=
{
created
:
-
1
};
if
(
orderBy
){
sort
=
orderBy
;
}
ForumComment
.
find
(
conditions
,
listCommentFields
).
populate
({
path
:
'from'
,
select
:
'uid mid nickName icon exp honorTitles'
}).
populate
(
'to'
,
'uid mid nickName icon exp'
).
limit
(
limit
).
skip
(
skip
).
sort
(
sort
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
obj
=
{};
obj
.
total
=
count
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
docs
;
callback
(
null
,
obj
);
}
});
}
});
};
//评论
function
populateComment
(
doc
,
callback
)
{
if
(
doc
&&
doc
.
comments
.
length
>
0
)
{
...
...
@@ -445,6 +479,54 @@ exports.getCommentListByMid = function(mid,conditions, pageNo, pageSize, callbac
};
exports
.
getCommentListByMidOrderBy
=
function
(
mid
,
conditions
,
orderBy
,
pageNo
,
pageSize
,
callback
)
{
//查询到用户
forumUserService
.
searchMembersByMid
(
mid
,
function
(
err
,
users
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
//查询对应用户的文章
var
user_ids
=
[];
for
(
var
i
in
users
){
user_ids
.
push
(
users
[
i
].
_id
);
}
conditions
.
from
=
{
$in
:
user_ids
}
countAll
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
callback
(
err
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sort
=
{
created
:
-
1
};
if
(
orderBy
){
sort
=
orderBy
;
}
ForumComment
.
find
(
conditions
).
populate
(
'from'
).
populate
(
'to'
).
limit
(
limit
).
skip
(
skip
).
sort
(
sort
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
obj
=
{};
obj
.
total
=
count
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
docs
;
callback
(
null
,
obj
);
}
});
}
});
}
});
};
exports
.
getCommentParent
=
function
(
cid
,
callback
)
{
ForumComment
.
findOne
({
comments
:
{
...
...
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