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
9056683e
Commit
9056683e
authored
Jul 15, 2015
by
陈家荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11
parent
6b8aa6c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
forumCommentService.js
app/service/forumCommentService.js
+12
-0
forumThreadService.js
app/service/forumThreadService.js
+73
-0
No files found.
app/service/forumCommentService.js
View file @
9056683e
...
@@ -43,6 +43,18 @@ exports.updateCommentStatusById=function(cid,status,callback){
...
@@ -43,6 +43,18 @@ exports.updateCommentStatusById=function(cid,status,callback){
});
});
};
};
//根据ID更新评论
exports
.
updateCommentFloorById
=
function
(
cid
,
floor
,
callback
){
ForumComment
.
update
({
_id
:
cid
},
{
"floor"
:
floor
},
null
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
//根据ID更新评论 entity
//根据ID更新评论 entity
exports
.
updateCommentById
=
function
(
cid
,
entity
,
callback
){
exports
.
updateCommentById
=
function
(
cid
,
entity
,
callback
){
ForumComment
.
update
({
_id
:
cid
},
entity
,
null
,
function
(
err
,
result
){
ForumComment
.
update
({
_id
:
cid
},
entity
,
null
,
function
(
err
,
result
){
...
...
app/service/forumThreadService.js
View file @
9056683e
...
@@ -536,6 +536,79 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
...
@@ -536,6 +536,79 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
});
});
}
}
function
getAllThreadByFidHelpNoLimit
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
countAllByFid
(
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
sortBy
=
'-topTime -tag_topTime -created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
ForumThread
.
find
(
conditions
).
populate
(
'from'
).
populate
(
'info'
).
populate
({
path
:
'tag'
}).
populate
({
path
:
'comments'
,
options
:
{
where
:{
status
:
1
},
sort
:
'created'
},
select
:
'from to created content'
}).
limit
(
limit
).
skip
(
skip
).
sort
(
sortBy
).
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
;
if
(
docs
&&
docs
.
length
>
0
)
{
var
asyncTasks
=
[];
docs
.
forEach
(
function
(
doc
)
{
// console.log(doc);
if
(
doc
.
type
===
1
||
doc
.
level
!==
1
)
{
//非照片墙或文章时获取评论
asyncTasks
.
push
(
function
(
callback
)
{
populateComment
(
doc
,
callback
);
});
}
else
{
asyncTasks
.
push
(
function
(
callback
)
{
getSubThreads
(
doc
,
null
,
callback
);
});
}
});
async
.
parallel
(
asyncTasks
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
null
,
null
);
}
else
{
obj
.
items
=
results
;
callback
(
null
,
obj
);
}
});
}
else
{
callback
(
null
,
obj
);
}
}
});
}
});
}
//获取全部列表数据
exports
.
getAllThreadByFidNoLimit
=
function
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
getAllThreadByFidHelpNoLimit
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
);
};
//获取全部列表数据
//获取全部列表数据
exports
.
getAllThreadByFid
=
function
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
exports
.
getAllThreadByFid
=
function
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
getAllThreadByFidHelp
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
);
getAllThreadByFidHelp
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
);
...
...
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