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
5cd8c8ae
Commit
5cd8c8ae
authored
Aug 28, 2015
by
陈志良
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Notice' of git.wxpai.cn:scrmgroup/pisns-forum-api into Notice
Conflicts: app/controllers/mobile/forumThread.js
parents
3926e6a1
472a46e9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
5 deletions
+106
-5
commentTips.js
app/controllers/mobile/commentTips.js
+4
-4
forumThread.js
app/controllers/mobile/forumThread.js
+10
-1
forumCommentService.js
app/service/forumCommentService.js
+92
-0
No files found.
app/controllers/mobile/commentTips.js
View file @
5cd8c8ae
...
@@ -17,7 +17,7 @@ router.get('/commentTips', function(req, res, next) {
...
@@ -17,7 +17,7 @@ router.get('/commentTips', function(req, res, next) {
if
(
err
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
(
{
data
:
result
}
,
returnCode
.
SUCCESS
));
}
}
});
});
});
});
...
@@ -29,19 +29,19 @@ router.put('/commentTips/:id', function(req, res, next) {
...
@@ -29,19 +29,19 @@ router.put('/commentTips/:id', function(req, res, next) {
if
(
err
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
(
{
data
:
result
}
,
returnCode
.
SUCCESS
));
}
}
});
});
});
});
router
.
p
u
t
(
'/commentTips/del'
,
function
(
req
,
res
,
next
)
{
router
.
p
os
t
(
'/commentTips/del'
,
function
(
req
,
res
,
next
)
{
var
userId
=
user
.
getMobileUser
(
req
);
var
userId
=
user
.
getMobileUser
(
req
);
var
entcode
=
req
.
session
.
user
.
ent_code
;
var
entcode
=
req
.
session
.
user
.
ent_code
;
commentTips
.
clear
(
entcode
,
userId
,
function
(
err
,
result
){
commentTips
.
clear
(
entcode
,
userId
,
function
(
err
,
result
){
if
(
err
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
(
{
data
:
result
}
,
returnCode
.
SUCCESS
));
}
}
});
});
});
});
\ No newline at end of file
app/controllers/mobile/forumThread.js
View file @
5cd8c8ae
...
@@ -14,7 +14,7 @@ var forumShareLogService = require('../../service/forumShareLogService');
...
@@ -14,7 +14,7 @@ var forumShareLogService = require('../../service/forumShareLogService');
var
forumCommentService
=
require
(
'../../service/forumCommentService'
);
var
forumCommentService
=
require
(
'../../service/forumCommentService'
);
var
forumUserThreadControlService
=
require
(
'../../service/forumUserThreadControlService'
);
var
forumUserThreadControlService
=
require
(
'../../service/forumUserThreadControlService'
);
var
forumLimitActionRefService
=
require
(
'../../service/forumLimitActionRefService'
);
var
forumLimitActionRefService
=
require
(
'../../service/forumLimitActionRefService'
);
var
commentTips
=
require
(
'../../utils/commentTips'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
user
=
require
(
'../../utils/user'
);
var
user
=
require
(
'../../utils/user'
);
...
@@ -506,6 +506,9 @@ router.post('/thread/:tid/comment/add', function(req, res, next) {
...
@@ -506,6 +506,9 @@ router.post('/thread/:tid/comment/add', function(req, res, next) {
if
(
err
)
{
if
(
err
)
{
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
if
(
user
.
getMobileUser
(
req
)
!==
thread
.
from
){
//文章的作者不等于评论的作者才增加消息数
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
thread
.
from
);
}
var
comments
=
thread
.
comments
;
var
comments
=
thread
.
comments
;
// console.log('=========');
// console.log('=========');
// console.log(comments);
// console.log(comments);
...
@@ -650,6 +653,9 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
...
@@ -650,6 +653,9 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
if
(
err
)
{
if
(
err
)
{
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
if
(
user
.
getMobileUser
(
req
)
!==
thread
.
from
){
//文章的作者不等于评论的作者才增加消息数
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
thread
.
from
);
}
var
comments
=
thread
.
comments
;
var
comments
=
thread
.
comments
;
// console.log('=========');
// console.log('=========');
// console.log(comments);
// console.log(comments);
...
@@ -808,6 +814,9 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
...
@@ -808,6 +814,9 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
if
(
err
)
{
if
(
err
)
{
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
if
(
user
.
getMobileUser
(
req
)
!==
req
.
body
.
to
){
//被评论人 和评论人不是同一个
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
req
.
body
.
to
);
}
var
comments
=
comment
.
comments
;
var
comments
=
comment
.
comments
;
var
array
=
[];
var
array
=
[];
if
(
comments
&&
comments
.
length
>
0
)
{
if
(
comments
&&
comments
.
length
>
0
)
{
...
...
app/service/forumCommentService.js
View file @
5cd8c8ae
...
@@ -301,3 +301,95 @@ exports.getPopulateCommentById=function(cid,callback){
...
@@ -301,3 +301,95 @@ exports.getPopulateCommentById=function(cid,callback){
}
}
});
});
};
};
//我的评论
var
countMyComment
=
function
(
conditions
,
callback
)
{
ForumComment
.
find
(
conditions
)
.
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
count
);
}
});
};
function
populateParentComment
(
doc
,
callback
){
if
(
doc
&&
doc
.
_id
&&
doc
.
level
===
2
)
{
ForumComment
.
findOne
({
comments
:
{
$elemMatch
:
doc
.
_id
},
status
:
1
}).
exec
(
function
(
err
,
c
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
null
,
null
);
}
else
{
if
(
c
){
callback
(
null
,
c
);
}
else
{
callback
(
null
);
}
}
});
}
else
{
callback
(
null
,
null
);
}
}
//我的评论
exports
.
getMyComment
=
function
(
conditions
,
pageNo
,
pageSize
,
callback
){
countMyComment
(
conditions
,
function
(
err
,
count
){
if
(
err
){
callback
(
err
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumComment
.
find
(
conditions
)
.
populate
({
path
:
'thread'
,
select
:
'_id content title type level tag'
}).
populate
({
path
:
'from to'
,
select
:
'uid nickName icon'
}).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
obj
=
{};
obj
.
total
=
count
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
docs
;
if
(
docs
&&
docs
.
length
>
0
)
{
var
asyncTasks
=
[];
docs
.
forEach
(
function
(
doc
){
asyncTasks
.
push
(
function
(
callback
)
{
populateParentComment
(
doc
,
function
(
err
,
c
){
if
(
err
){
callback
(
err
,
null
);
}
else
{
var
newobj
=
doc
.
toObject
();
newobj
.
parent
=
c
;
delete
newobj
.
comments
;
callback
(
null
,
newobj
);
}
});
});
});
async
.
parallel
(
asyncTasks
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
callback
(
null
,
null
);
}
else
{
obj
.
items
=
results
;
callback
(
null
,
obj
);
}
});
}
else
{
callback
(
null
,
obj
);
}
}
});
}
});
};
\ No newline at end of file
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