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
3f70ee4e
Commit
3f70ee4e
authored
Apr 24, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of git.wxpai.cn:scrmgroup/pisns-forum-api into development
parents
adc59954
8eb70843
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
21 deletions
+58
-21
forumThread.js
app/controllers/admin/forumThread.js
+50
-18
forumThreadService.js
app/service/forumThreadService.js
+8
-3
No files found.
app/controllers/admin/forumThread.js
View file @
3f70ee4e
...
@@ -30,7 +30,9 @@ router.post('/thread/create', function(req, res, next) {
...
@@ -30,7 +30,9 @@ router.post('/thread/create', function(req, res, next) {
var
rs
=
{};
var
rs
=
{};
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
req
.
body
.
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
!
req
.
body
.
share
){
delete
req
.
body
.
share
;
}
var
uid
=
req
.
session
.
user
.
id
;
var
uid
=
req
.
session
.
user
.
id
;
// var uid='12345';
// var uid='12345';
if
(
req
.
body
.
pid
)
{
if
(
req
.
body
.
pid
)
{
...
@@ -81,7 +83,9 @@ router.post('/thread/create', function(req, res, next) {
...
@@ -81,7 +83,9 @@ router.post('/thread/create', function(req, res, next) {
}
}
});
});
}
}
});
}
}
});
}
}
});
});
});
});
...
@@ -113,9 +117,20 @@ router.get('/thread/:tid/get', function(req, res, next) {
...
@@ -113,9 +117,20 @@ router.get('/thread/:tid/get', function(req, res, next) {
if
(
err
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
rs
.
data
=
results
[
0
];
rs
.
tagList
=
results
[
1
];
if
(
results
[
0
].
pid
)
{
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
forumThreadService
.
getById
(
results
[
0
].
pid
,
function
(
err
,
parentThread
)
{
rs
.
data
=
results
[
0
];
rs
.
tagList
=
results
[
1
];
rs
.
parentThread
=
parentThread
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
});
}
else
{
rs
.
data
=
results
[
0
];
rs
.
tagList
=
results
[
1
];
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
}
}
});
});
}
else
{
}
else
{
...
@@ -229,7 +244,7 @@ router.get('/threads/list', function(req, res, next) {
...
@@ -229,7 +244,7 @@ router.get('/threads/list', function(req, res, next) {
conditions
.
level
=
2
;
conditions
.
level
=
2
;
}
}
if
(
content
)
{
if
(
content
)
{
conditions
.
content
=
{
conditions
.
content
=
{
$regex
:
content
,
$regex
:
content
,
$options
:
'i'
$options
:
'i'
...
@@ -241,7 +256,16 @@ router.get('/threads/list', function(req, res, next) {
...
@@ -241,7 +256,16 @@ router.get('/threads/list', function(req, res, next) {
console
.
error
(
err
);
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
if
(
results
.
items
.
length
>
0
&&
results
.
items
[
0
].
pid
)
{
forumThreadService
.
getById
(
results
.
items
[
0
].
pid
,
function
(
err
,
parentThread
)
{
res
.
json
(
_
.
assign
({
parentThread
:
parentThread
},
results
,
returnCode
.
SUCCESS
));
});
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
}
}
});
});
});
});
...
@@ -298,7 +322,7 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
...
@@ -298,7 +322,7 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
forumThreadService
.
getById
(
tid
,
function
(
err
,
result
)
{
forumThreadService
.
getById
(
tid
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
result
.
comment_count
-=
1
;
result
.
comment_count
-=
1
;
var
commentList
=
result
.
comments
;
var
commentList
=
result
.
comments
;
...
@@ -306,7 +330,7 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
...
@@ -306,7 +330,7 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
forumThreadService
.
updateThreadById
(
tid
,
result
,
function
(
err
,
result
)
{
forumThreadService
.
updateThreadById
(
tid
,
result
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
res
.
json
(
returnCode
.
SUCCESS
);
}
}
...
@@ -316,9 +340,9 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
...
@@ -316,9 +340,9 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
}
else
{
// 删除子评论
}
else
{
// 删除子评论
// 更新文章评论 - 1
// 更新文章评论 - 1
forumThreadService
.
updateThreadCommentCount
(
tid
,
comment_count
-
1
,
function
(
err
,
result
)
{
forumThreadService
.
updateThreadCommentCount
(
tid
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
callback
(
err
,
null
);
res
.
json
(
returnCode
.
BUSY
);
}
}
});
});
...
@@ -327,7 +351,7 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
...
@@ -327,7 +351,7 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
forumCommentService
.
getCommentById
(
parent_cid
,
function
(
err
,
result
)
{
forumCommentService
.
getCommentById
(
parent_cid
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
var
commentList
=
result
.
comments
;
var
commentList
=
result
.
comments
;
result
.
comments
=
forumCommentService
.
remove
(
commentList
,
cid
);
result
.
comments
=
forumCommentService
.
remove
(
commentList
,
cid
);
...
@@ -372,7 +396,14 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
...
@@ -372,7 +396,14 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
});
});
// 更新评论对象
// 更新评论对象
// result.comment_count+=1; // 回复评论+1
// result.comment_count+=1; // 回复评论+1
forumCommentService
.
updateCommentById
(
cid
,
{
$push
:{
comments
:
replayComment_id
},
$inc
:{
comment_count
:
1
}},
function
(
err
,
result
)
{
forumCommentService
.
updateCommentById
(
cid
,
{
$push
:
{
comments
:
replayComment_id
},
$inc
:
{
comment_count
:
1
}
},
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
...
@@ -390,15 +421,15 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
...
@@ -390,15 +421,15 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
forumCommentService
.
getCommentById
(
cid
,
function
(
err
,
result
)
{
forumCommentService
.
getCommentById
(
cid
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
var
commentList
=
result
.
comments
;
var
commentList
=
result
.
comments
;
result
.
comments
.
push
(
replayComment_id
);
result
.
comments
.
push
(
replayComment_id
);
forumCommentService
.
updateCommentById
(
cid
,
result
,
function
(
err
,
result
)
{
forumCommentService
.
updateCommentById
(
cid
,
result
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
res
.
json
(
returnCode
.
SUCCESS
);
...
@@ -455,6 +486,7 @@ router.post('/thread/comment/add', function(req, res, next) {
...
@@ -455,6 +486,7 @@ router.post('/thread/comment/add', function(req, res, next) {
};
};
forumUserService
.
createUser
(
userentity
,
function
(
err
,
doc
)
{
forumUserService
.
createUser
(
userentity
,
function
(
err
,
doc
)
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
entity
.
from
=
doc
.
_id
;
entity
.
from
=
doc
.
_id
;
...
@@ -480,7 +512,7 @@ router.post('/thread/comment/add', function(req, res, next) {
...
@@ -480,7 +512,7 @@ router.post('/thread/comment/add', function(req, res, next) {
res
.
json
(
returnCode
.
WRONG_PARAM
);
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
}
// 测试环境
// 测试环境
// entity.from = '55015675868b65a028187c49';
// entity.from = '55015675868b65a028187c49';
...
@@ -510,7 +542,7 @@ router.post('/thread/:tid/updateComments', function(req, res, next) {
...
@@ -510,7 +542,7 @@ router.post('/thread/:tid/updateComments', function(req, res, next) {
forumThreadService
.
getById
(
tid
,
function
(
err
,
result
)
{
forumThreadService
.
getById
(
tid
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
result
.
comments
.
push
(
cid
);
result
.
comments
.
push
(
cid
);
result
.
comment_count
+=
1
;
result
.
comment_count
+=
1
;
...
@@ -518,7 +550,7 @@ router.post('/thread/:tid/updateComments', function(req, res, next) {
...
@@ -518,7 +550,7 @@ router.post('/thread/:tid/updateComments', function(req, res, next) {
forumThreadService
.
updateThreadById
(
tid
,
result
,
function
(
err
,
result
)
{
forumThreadService
.
updateThreadById
(
tid
,
result
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
res
.
json
(
returnCode
.
SUCCESS
);
}
}
...
...
app/service/forumThreadService.js
View file @
3f70ee4e
...
@@ -674,12 +674,17 @@ exports.updateThreadCommentCountInc = function(threadId, callback) {
...
@@ -674,12 +674,17 @@ exports.updateThreadCommentCountInc = function(threadId, callback) {
};
};
//更新文章评论数
//更新文章评论数
exports
.
updateThreadCommentCount
=
function
(
threadId
,
c
omment_count
,
c
allback
)
{
exports
.
updateThreadCommentCount
=
function
(
threadId
,
callback
)
{
ForumThread
.
update
({
ForumThread
.
update
({
_id
:
threadId
_id
:
threadId
},
{
},
{
'comment_count'
:
comment_count
$inc
:
{
},
null
,
comment_count
:
-
1
}
},
{
w
:
1
,
safe
:
true
},
function
(
err
,
result
)
{
function
(
err
,
result
)
{
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