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
bdadbb88
Commit
bdadbb88
authored
Mar 10, 2016
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
二级评论不过滤掉 又前端判断显示方式
parent
5900fbe2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
220 additions
and
3 deletions
+220
-3
forumThread.js
app/controllers/mobile/forumThread.js
+108
-0
forumCommentService.js
app/service/forumCommentService.js
+106
-0
user.js
app/utils/user.js
+6
-3
No files found.
app/controllers/mobile/forumThread.js
View file @
bdadbb88
...
@@ -1474,7 +1474,115 @@ router.get('/thread/:tid/comment/list/byFloor', function(req, res, next) {
...
@@ -1474,7 +1474,115 @@ router.get('/thread/:tid/comment/list/byFloor', function(req, res, next) {
}
}
});
});
//不过滤掉已删除的二级评论
router
.
get
(
'/thread/:tid/comment/list/all'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
tid
=
req
.
params
.
tid
||
null
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
conditions
=
{
ent_code
:
ent_code
,
thread
:
tid
,
level
:
'1'
};
if
(
tid
)
{
//获取最新5条评论
forumCommentService
.
getAllComment_allstatus
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
//判断是否已经点赞
util
.
loadLevel
(
req
.
session
.
user
.
ent_code
,
results
.
items
,
function
()
{
redisPraiseLog
.
get
(
ent_code
,
user
.
getMobileUser
(
req
),
'comment'
,
function
(
error
,
docs
)
{
_
.
forEach
(
results
.
items
,
function
(
d
,
i
)
{
if
(
results
.
items
[
i
].
toObject
)
{
results
.
items
[
i
]
=
results
.
items
[
i
].
toObject
();
}
results
.
items
[
i
].
isPraise
=
false
;
for
(
var
k
=
docs
.
length
-
1
;
k
>=
0
;
k
--
)
{
if
(
results
.
items
[
i
].
_id
==
docs
[
k
])
{
results
.
items
[
i
].
isPraise
=
true
;
break
;
}
};
});
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
});
});
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//不过滤掉已删除的二级评论
router
.
get
(
'/thread/:tid/comment/list/byFloor/all'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
floor
=
req
.
query
.
floor
||
1
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
countConditions
=
{
ent_code
:
ent_code
,
thread
:
tid
,
level
:
'1'
};
var
conditions
=
{
ent_code
:
ent_code
,
thread
:
tid
,
level
:
'1'
,
floor
:
{
'$gte'
:
floor
-
9
,
'$lte'
:
floor
}
};
if
(
tid
)
{
//获取最新5条评论
forumCommentService
.
count
(
countConditions
,
function
(
err
,
count
)
{
if
(
err
)
{
console
.
log
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumCommentService
.
getAllComment_allstatus
(
conditions
,
1
,
10
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
//判断是否已经点赞
util
.
loadLevel
(
req
.
session
.
user
.
ent_code
,
results
.
items
,
function
()
{
redisPraiseLog
.
get
(
ent_code
,
user
.
getMobileUser
(
req
),
'comment'
,
function
(
error
,
docs
)
{
_
.
forEach
(
results
.
items
,
function
(
d
,
i
)
{
if
(
results
.
items
[
i
].
toObject
)
{
results
.
items
[
i
]
=
results
.
items
[
i
].
toObject
();
}
results
.
items
[
i
].
isPraise
=
false
;
for
(
var
k
=
docs
.
length
-
1
;
k
>=
0
;
k
--
)
{
if
(
results
.
items
[
i
].
_id
==
docs
[
k
])
{
results
.
items
[
i
].
isPraise
=
true
;
break
;
}
};
});
results
.
total
=
count
;
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
});
});
}
});
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//评论点赞
//评论点赞
router
.
post
(
'/thread/:tid/comment/:cid/raise'
,
function
(
req
,
res
,
next
)
{
router
.
post
(
'/thread/:tid/comment/:cid/raise'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
...
...
app/service/forumCommentService.js
View file @
bdadbb88
...
@@ -616,3 +616,109 @@ exports.getAllCommentByThread = function(conditions, callback) {
...
@@ -616,3 +616,109 @@ exports.getAllCommentByThread = function(conditions, callback) {
}
}
});
});
};
};
/**
* 20160310
* 查询评论列表(包含已删除的二级评论)
*
* **/
exports
.
getAllComment_allstatus
=
function
(
conditions
,
pageNo
,
pageSize
,
callback
)
{
countAll
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumComment
.
find
(
conditions
,
listCommentFields
).
populate
(
'from'
,
'uid mid nickName icon exp'
).
populate
(
'to'
,
'uid mid nickName icon exp'
).
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
)
{
populateComment_allstatus
(
doc
,
function
(
err
,
c
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
var
newobj
=
doc
.
toObject
();
newobj
.
comments
=
(
c
==
null
?
[]
:
c
);
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
);
}
}
});
}
});
};
//评论
function
populateComment_allstatus
(
doc
,
callback
)
{
if
(
doc
&&
doc
.
comments
.
length
>
0
)
{
var
asyncTasks
=
[];
doc
.
comments
.
forEach
(
function
(
comment
)
{
asyncTasks
.
push
(
function
(
callback
)
{
ForumComment
.
findOne
({
_id
:
comment
}).
populate
({
path
:
'from to'
,
select
:
'uid nickName icon mid'
}).
exec
(
function
(
err
,
c
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
null
,
null
);
}
else
{
if
(
c
)
{
callback
(
null
,
c
);
}
else
{
callback
(
null
);
}
}
});
});
});
async
.
parallel
(
asyncTasks
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
log
(
err
);
callback
(
null
,
null
);
}
else
{
var
comments
=
[];
for
(
var
i
=
0
;
i
<
results
.
length
;
i
+=
1
)
{
if
(
results
[
i
])
{
comments
.
push
(
results
[
i
]);
}
}
callback
(
null
,
comments
);
}
});
}
else
{
callback
(
null
,
null
);
}
}
app/utils/user.js
View file @
bdadbb88
...
@@ -23,7 +23,8 @@ exports.identifyUser=function() {
...
@@ -23,7 +23,8 @@ exports.identifyUser=function() {
if
(
doc
){
if
(
doc
){
req
.
session
.
mobileForumUser
=
{
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
userId
:
doc
.
_id
,
openId
:
doc
.
uid
openId
:
doc
.
uid
,
mid
:
doc
.
mid
};
};
if
(
req
.
session
.
source
){
if
(
req
.
session
.
source
){
if
(
req
.
session
.
source
!==
req
.
session
.
mobileForumUser
.
userId
){
if
(
req
.
session
.
source
!==
req
.
session
.
mobileForumUser
.
userId
){
...
@@ -41,7 +42,8 @@ exports.identifyUser=function() {
...
@@ -41,7 +42,8 @@ exports.identifyUser=function() {
uid
:
req
.
session
.
openUser
.
openId
,
uid
:
req
.
session
.
openUser
.
openId
,
nickName
:
req
.
session
.
openUser
.
nickName
,
nickName
:
req
.
session
.
openUser
.
nickName
,
icon
:
req
.
session
.
openUser
.
headPic
,
icon
:
req
.
session
.
openUser
.
headPic
,
ent_code
:
req
.
session
.
user
.
ent_code
ent_code
:
req
.
session
.
user
.
ent_code
,
mid
:
req
.
session
.
openUser
.
mid
};
};
forumUserService
.
createUser
(
entity
,
function
(
err
,
doc
){
forumUserService
.
createUser
(
entity
,
function
(
err
,
doc
){
if
(
err
){
if
(
err
){
...
@@ -49,7 +51,8 @@ exports.identifyUser=function() {
...
@@ -49,7 +51,8 @@ exports.identifyUser=function() {
}
else
{
}
else
{
req
.
session
.
mobileForumUser
=
{
req
.
session
.
mobileForumUser
=
{
userId
:
doc
.
_id
,
userId
:
doc
.
_id
,
openId
:
doc
.
uid
openId
:
doc
.
uid
,
mid
:
doc
.
mid
};
};
if
(
req
.
session
.
source
){
if
(
req
.
session
.
source
){
if
(
req
.
session
.
source
!==
req
.
session
.
mobileForumUser
.
userId
){
if
(
req
.
session
.
source
!==
req
.
session
.
mobileForumUser
.
userId
){
...
...
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