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
3e3442e8
Commit
3e3442e8
authored
Apr 24, 2015
by
陈家荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gggg
parent
3f70ee4e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
35 deletions
+70
-35
forumThread.js
app/controllers/admin/forumThread.js
+70
-35
No files found.
app/controllers/admin/forumThread.js
View file @
3e3442e8
...
...
@@ -30,7 +30,7 @@ router.post('/thread/create', function(req, res, next) {
var
rs
=
{};
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
!
req
.
body
.
share
)
{
if
(
!
req
.
body
.
share
)
{
delete
req
.
body
.
share
;
}
var
uid
=
req
.
session
.
user
.
id
;
...
...
@@ -117,7 +117,7 @@ router.get('/thread/:tid/get', function(req, res, next) {
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
results
[
0
].
pid
)
{
forumThreadService
.
getById
(
results
[
0
].
pid
,
function
(
err
,
parentThread
)
{
rs
.
data
=
results
[
0
];
...
...
@@ -256,8 +256,8 @@ router.get('/threads/list', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
results
.
items
.
length
>
0
&&
results
.
items
[
0
].
pid
)
{
if
(
results
.
items
.
length
>
0
&&
results
.
items
[
0
].
pid
)
{
forumThreadService
.
getById
(
results
.
items
[
0
].
pid
,
function
(
err
,
parentThread
)
{
res
.
json
(
_
.
assign
({
parentThread
:
parentThread
...
...
@@ -324,10 +324,19 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
result
.
comment_count
-=
1
;
// result.comment_count -= 1;
// var commentList = result.comments;
// result.comments = forumThreadService.remove(commentList, cid);
var
commentList
=
result
.
comments
;
result
.
comments
=
forumThreadService
.
remove
(
commentList
,
cid
);
forumThreadService
.
updateThreadById
(
tid
,
result
,
function
(
err
,
result
)
{
var
comments
=
forumThreadService
.
remove
(
commentList
,
cid
);
forumThreadService
.
updateThreadById
(
tid
,
{
comments
:
comments
,
$inc
:
{
comment_count
:
-
1
}
},
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -354,8 +363,10 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
commentList
=
result
.
comments
;
result
.
comments
=
forumCommentService
.
remove
(
commentList
,
cid
);
forumCommentService
.
updateCommentById
(
parent_cid
,
result
,
function
(
err
,
result
)
{
var
comments
=
forumCommentService
.
remove
(
commentList
,
cid
);
forumCommentService
.
updateCommentById
(
parent_cid
,
{
comments
:
comments
},
function
(
err
,
result
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
...
...
@@ -427,14 +438,19 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
result
.
comments
.
push
(
replayComment_id
);
forumCommentService
.
updateCommentById
(
cid
,
result
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
forumCommentService
.
updateCommentById
(
cid
,
{
$push
:
{
comments
:
replayComment_id
}
},
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
});
...
...
@@ -538,25 +554,44 @@ router.post('/thread/comment/add', function(req, res, next) {
router
.
post
(
'/thread/:tid/updateComments'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
cid
=
req
.
body
.
cid
||
null
;
// 获取评论的子评论列表
forumThreadService
.
getById
(
tid
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
result
.
comments
.
push
(
cid
);
result
.
comment_count
+=
1
;
forumThreadService
.
updateThreadById
(
tid
,
result
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
});
forumThreadService
.
updateThreadById
(
tid
,
{
$push
:
{
comments
:
cid
},
$inc
:
{
comment_count
:
1
}
},
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
// 获取评论的子评论列表
// forumThreadService.getById(tid, function(err, result) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// result.comments.push(cid);
// result.comment_count += 1;
// forumThreadService.updateThreadById(tid, result,
// function(err, result) {
// if (err) {
// console.error(err);
// res.json(returnCode.BUSY);
// } else {
// res.json(returnCode.SUCCESS);
// }
// });
// }
// });
});
...
...
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