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
7059dc89
Commit
7059dc89
authored
Apr 21, 2015
by
邓军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
子文章管理
parent
114142af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
forumThreadService.js
app/service/forumThreadService.js
+21
-16
No files found.
app/service/forumThreadService.js
View file @
7059dc89
...
...
@@ -10,14 +10,14 @@ var async = require('async');
var
then
=
require
(
'thenjs'
);
//查询帖子
exports
.
findThreadByPage
=
function
(
pageNo
,
pageSize
,
q
,
callback
)
{
exports
.
findThreadByPage
=
function
(
pageNo
,
pageSize
,
q
,
callback
)
{
then
(
function
(
cont
)
{
ForumThread
.
find
(
q
).
populate
(
'from'
).
count
(
cont
);
}).
then
(
function
(
cont
,
count
)
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumThread
.
find
(
q
).
skip
(
skip
).
limit
(
limit
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
cont
(
err
,
count
,
docs
);
});
}).
then
(
function
(
cont
,
count
,
threads
)
{
...
...
@@ -26,28 +26,28 @@ exports.findThreadByPage = function(pageNo,pageSize,q,callback) {
total
:
count
,
datas
:
threads
};
callback
(
null
,
rsJson
);
callback
(
null
,
rsJson
);
}).
fail
(
function
(
cont
,
err
)
{
console
.
error
(
err
);
var
rsJson
=
{
result
:
false
,
err
:
err
};
callback
(
err
,
rsJson
);
callback
(
err
,
rsJson
);
});
};
//查询评论
exports
.
findCommentByPage
=
function
(
pageNo
,
pageSize
,
q
,
callback
)
{
exports
.
findCommentByPage
=
function
(
pageNo
,
pageSize
,
q
,
callback
)
{
then
(
function
(
cont
)
{
ForumComment
.
find
(
q
).
populate
(
'from'
).
count
(
cont
);
}).
then
(
function
(
cont
,
count
)
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumComment
.
find
(
q
).
skip
(
skip
).
limit
(
limit
).
sort
(
'-created'
).
populate
(
'from'
).
exec
(
function
(
err
,
docs
)
{
cont
(
err
,
count
,
docs
);
});
}).
then
(
function
(
cont
,
count
,
threads
)
{
...
...
@@ -56,15 +56,15 @@ exports.findCommentByPage = function(pageNo,pageSize,q,callback) {
total
:
count
,
datas
:
threads
};
callback
(
null
,
rsJson
);
callback
(
null
,
rsJson
);
}).
fail
(
function
(
cont
,
err
)
{
console
.
error
(
err
);
var
rsJson
=
{
result
:
false
,
err
:
err
};
callback
(
err
,
rsJson
);
callback
(
err
,
rsJson
);
});
};
...
...
@@ -254,8 +254,13 @@ exports.getThreadById = function(tid, callback) {
//根据ID更新文章
exports
.
updateThreadById
=
function
(
tid
,
entity
,
callback
)
{
var
shareEntity
=
entity
.
share
;
entity
.
share
=
entity
.
share
.
_id
;
if
(
entity
.
share
.
_id
)
{
entity
.
share
=
entity
.
share
.
_id
;
}
else
{
entity
.
share
=
''
;
}
if
(
entity
.
share
)
{
ForumThread
.
update
({
_id
:
tid
},
entity
,
null
,
function
(
err
,
result
)
{
...
...
@@ -265,12 +270,12 @@ exports.updateThreadById = function(tid, entity, callback) {
}
else
{
ForumShare
.
update
({
_id
:
shareEntity
.
_id
},
shareEntity
,
null
,
function
(
err
,
result
)
{
},
shareEntity
,
null
,
function
(
err
,
se
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
callback
(
null
,
entity
);
}
});
...
...
@@ -291,7 +296,7 @@ exports.updateThreadById = function(tid, entity, callback) {
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
callback
(
null
,
entity
);
}
});
...
...
@@ -305,7 +310,7 @@ exports.updateThreadById = function(tid, entity, callback) {
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
callback
(
null
,
entity
);
}
});
...
...
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