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
21b08a66
Commit
21b08a66
authored
Apr 22, 2015
by
邓军
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of git.wxpai.cn:scrmgroup/pisns-forum-api into development
parents
021f8437
ea7c891e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
7 deletions
+68
-7
forumThread.js
app/controllers/admin/forumThread.js
+36
-4
forumThread.js
app/controllers/mobile/forumThread.js
+7
-0
forumComment.js
app/models/forumComment.js
+5
-0
forumCommentService.js
app/service/forumCommentService.js
+20
-3
No files found.
app/controllers/admin/forumThread.js
View file @
21b08a66
...
@@ -259,13 +259,13 @@ router.get('/thread/:tid/comment/list', function(req, res, next) {
...
@@ -259,13 +259,13 @@ router.get('/thread/:tid/comment/list', function(req, res, next) {
}
}
});
});
// 更新评论
// 更新评论
状态
router
.
post
(
'/thread/comment/update/:cid'
,
function
(
req
,
res
,
next
){
router
.
post
(
'/thread/comment/update/:cid'
,
function
(
req
,
res
,
next
){
var
cid
=
req
.
params
.
cid
||
null
;
var
cid
=
req
.
params
.
cid
||
null
;
var
status
=
req
.
body
.
status
;
var
status
=
req
.
body
.
status
;
if
(
cid
){
if
(
cid
){
forumCommentService
.
updateCommentById
(
cid
,
status
,
function
(
err
,
result
){
forumCommentService
.
updateComment
Status
ById
(
cid
,
status
,
function
(
err
,
result
){
if
(
err
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
...
@@ -278,6 +278,35 @@ router.post('/thread/comment/update/:cid',function(req,res,next){
...
@@ -278,6 +278,35 @@ router.post('/thread/comment/update/:cid',function(req,res,next){
});
});
// 更新回复评论
router
.
post
(
'/thread/comment/update/:cid/comments'
,
function
(
req
,
res
,
next
){
var
cid
=
req
.
params
.
cid
||
null
;
var
replayComment_id
=
req
.
body
.
replayComment_id
;
// 获取评论的子评论列表
forumCommentService
.
getCommentById
(
cid
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
commentList
=
result
.
comments
;
console
.
log
(
'准备插入:'
+
replayComment_id
);
console
.
log
(
result
.
_id
);
result
.
comments
.
push
(
replayComment_id
);
forumCommentService
.
updateCommentById
(
cid
,
result
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
});
});
//添加评论
//添加评论
router
.
post
(
'/thread/comment/add'
,
function
(
req
,
res
,
next
)
{
router
.
post
(
'/thread/comment/add'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
body
.
tid
||
null
;
var
tid
=
req
.
body
.
tid
||
null
;
...
@@ -292,9 +321,12 @@ router.post('/thread/comment/add', function(req, res, next) {
...
@@ -292,9 +321,12 @@ router.post('/thread/comment/add', function(req, res, next) {
if
(
err
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
var
returnData
=
{
// returnCode.SUCCESS,
comment
:
result
}
res
.
json
(
returnData
);
}
}
});
});
}
}
});
});
\ No newline at end of file
app/controllers/mobile/forumThread.js
View file @
21b08a66
...
@@ -687,8 +687,15 @@ router.post('/thread/:tid/comment/:cid/delete', function(req, res, next) {
...
@@ -687,8 +687,15 @@ router.post('/thread/:tid/comment/:cid/delete', function(req, res, next) {
//评论列表
//评论列表
router
.
get
(
'/thread/:tid/comment/list'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'/thread/:tid/comment/list'
,
function
(
req
,
res
,
next
)
{
<<<<<<<
HEAD
var
tid
=
req
.
params
.
tid
||
null
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
=======
var
tid
=
req
.
params
.
tid
||
null
;
var
tid
=
req
.
params
.
tid
||
null
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
>>>>>>>
f2a61e4b468be1158deee3015cb171b0bede90e4
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
conditions
=
{
var
conditions
=
{
...
...
app/models/forumComment.js
View file @
21b08a66
...
@@ -50,6 +50,11 @@ var ForumCommentSchema = new Schema({
...
@@ -50,6 +50,11 @@ var ForumCommentSchema = new Schema({
require
:
true
,
require
:
true
,
default
:
0
default
:
0
},
},
status
:
{
//文章状态,1启用,0禁用,2需审核
type
:
Number
,
require
:
true
,
default
:
1
},
created
:
{
//评论时间
created
:
{
//评论时间
type
:
Date
,
type
:
Date
,
require
:
true
,
require
:
true
,
...
...
app/service/forumCommentService.js
View file @
21b08a66
'use strict'
;
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
mongoose
=
require
(
'mongoose'
);
var
ForumComment
=
mongoose
.
model
(
'ForumComment'
);
var
ForumComment
=
mongoose
.
model
(
'ForumComment'
);
...
@@ -30,18 +32,33 @@ exports.getCommentById=function(cid,callback){
...
@@ -30,18 +32,33 @@ exports.getCommentById=function(cid,callback){
};
};
//根据ID更新评论
//根据ID更新评论
exports
.
updateCommentStatusById
=
function
(
cid
,
status
,
callback
){
ForumComment
.
update
({
_id
:
cid
},
{
"status"
:
status
},
null
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
console
.
log
(
result
);
callback
(
null
,
null
);
}
});
};
//根据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
){
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
console
.
log
(
result
);
callback
(
null
,
null
);
callback
(
null
,
null
);
}
}
});
});
};
};
//根据ID更新评论
//根据ID删除评论
exports
.
deleteCommentById
=
function
(
cid
,
callback
){
exports
.
deleteCommentById
=
function
(
cid
,
callback
){
ForumComment
.
remove
({
_id
:
cid
},
function
(
err
,
result
){
ForumComment
.
remove
({
_id
:
cid
},
function
(
err
,
result
){
if
(
err
)
{
if
(
err
)
{
...
@@ -74,7 +91,7 @@ exports.getAllComment= function(conditions,pageNo,pageSize,callback) {
...
@@ -74,7 +91,7 @@ exports.getAllComment= function(conditions,pageNo,pageSize,callback) {
}
else
{
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
console
.
log
(
"count:"
+
count
);
ForumComment
.
find
(
conditions
).
populate
(
'from'
).
populate
(
'to'
).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
ForumComment
.
find
(
conditions
).
populate
(
'from'
).
populate
(
'to'
).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
...
...
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