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
80968d60
Commit
80968d60
authored
Apr 24, 2015
by
陈志良
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微社区
parent
9ea176ea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
24 deletions
+28
-24
forumThread.js
app/controllers/admin/forumThread.js
+4
-9
forumThread.js
app/controllers/mobile/forumThread.js
+2
-1
forumCommentService.js
app/service/forumCommentService.js
+13
-4
forumThreadService.js
app/service/forumThreadService.js
+9
-10
No files found.
app/controllers/admin/forumThread.js
View file @
80968d60
...
...
@@ -336,11 +336,11 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
// var commentList = result.comments;
// result.comments = forumThreadService.remove(commentList, cid);
//
var commentList = result.comments;
//
var comments = forumThreadService.remove(commentList, cid);
var
commentList
=
result
.
comments
;
var
comments
=
forumThreadService
.
remove
(
commentList
,
cid
);
forumThreadService
.
updateThreadById
(
tid
,
{
"$pull"
:
{
"comments"
:
{
"_id"
:
cid
}}
,
comments
:
comments
,
$inc
:
{
comment_count
:
-
1
}
},
function
(
err
,
result
)
{
if
(
err
)
{
...
...
@@ -371,12 +371,7 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
var
commentList
=
result
.
comments
;
var
comments
=
forumCommentService
.
remove
(
commentList
,
cid
);
forumCommentService
.
updateCommentById
(
parent_cid
,
{
"$pull"
:
{
"comments"
:
{
"_id"
:
cid
}
}
comments
:
comments
},
function
(
err
,
result
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
...
...
app/controllers/mobile/forumThread.js
View file @
80968d60
...
...
@@ -698,7 +698,8 @@ router.get('/thread/:tid/comment/list', function(req, res, next) {
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
thread
:
tid
,
level
:
'1'
level
:
'1'
,
status
:
1
};
if
(
tid
)
{
...
...
app/service/forumCommentService.js
View file @
80968d60
...
...
@@ -142,12 +142,16 @@ function populateComment(doc, callback){
var
asyncTasks
=
[];
doc
.
comments
.
forEach
(
function
(
comment
){
asyncTasks
.
push
(
function
(
callback
)
{
ForumComment
.
findOne
({
_id
:
comment
}).
populate
({
path
:
'from to'
,
select
:
'uid nickName icon'
}).
exec
(
function
(
err
,
c
){
ForumComment
.
findOne
({
_id
:
comment
,
status
:
1
}).
populate
({
path
:
'from to'
,
select
:
'uid nickName icon'
}).
exec
(
function
(
err
,
c
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
null
,
null
);
}
else
{
callback
(
null
,
c
);
if
(
c
){
callback
(
null
,
c
);
}
else
{
callback
(
null
);
}
}
});
});
...
...
@@ -157,8 +161,13 @@ function populateComment(doc, callback){
console
.
log
(
err
);
callback
(
null
,
null
);
}
else
{
// console.log(results);
callback
(
null
,
results
);
var
comments
=
[];
for
(
var
i
=
0
;
i
<
results
.
length
;
i
+=
1
){
if
(
results
[
i
]){
comments
.
push
(
results
[
i
]);
}
}
callback
(
null
,
comments
);
}
});
...
...
app/service/forumThreadService.js
View file @
80968d60
...
...
@@ -129,25 +129,20 @@ exports.getThreadById = function(tid, callback) {
var
conditions
=
{
_id
:
tid
};
ForumThread
.
find
(
conditions
).
populate
(
'from'
).
populate
(
'info'
).
populate
(
'share'
).
exec
(
function
(
err
,
docs
)
{
ForumThread
.
find
One
(
conditions
).
populate
(
'from'
).
populate
(
'info'
).
populate
(
'share'
).
exec
(
function
(
err
,
doc
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
thread
=
{};
if
(
docs
&&
docs
.
length
>
0
)
{
thread
=
docs
[
0
];
cb
(
null
,
thread
);
}
else
{
cb
(
null
,
thread
);
}
cb
(
null
,
doc
);
}
});
},
function
(
cb
)
{
var
conditions
=
{
thread
:
tid
,
level
:
'1'
level
:
'1'
,
status
:
1
};
//获取最新10条评论
forumCommentService
.
getAllComment
(
conditions
,
1
,
10
,
function
(
err
,
results
)
{
...
...
@@ -163,7 +158,8 @@ exports.getThreadById = function(tid, callback) {
//获取话题子文章列表
var
conditions
=
{
pid
:
tid
,
type
:
2
type
:
2
,
status
:
1
};
getAllThreadByFidHelp
(
conditions
,
1
,
10
,
null
,
function
(
err
,
threads
)
{
if
(
err
)
{
...
...
@@ -180,6 +176,7 @@ exports.getThreadById = function(tid, callback) {
var
conditions
=
{
pid
:
tid
,
type
:
3
,
status
:
1
,
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
};
getAllThreadByFidHelp
(
conditions
,
1
,
10
,
'-created'
,
function
(
err
,
threads
)
{
...
...
@@ -196,6 +193,7 @@ exports.getThreadById = function(tid, callback) {
var
conditions
=
{
pid
:
tid
,
type
:
3
,
status
:
1
,
images
:
{
$exists
:
true
,
$not
:
{
$size
:
0
}}
};
getAllThreadByFidHelp
(
conditions
,
1
,
10
,
'-praise_count'
,
function
(
err
,
threads
)
{
...
...
@@ -487,6 +485,7 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
}).
populate
({
path
:
'comments'
,
options
:
{
where
:{
status
:
1
},
limit
:
5
,
sort
:
'-created'
},
...
...
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