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
742dca0d
Commit
742dca0d
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
065902a8
50bc31e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
23 deletions
+111
-23
forumComplaint.js
app/controllers/admin/forumComplaint.js
+12
-0
forumThread.js
app/controllers/admin/forumThread.js
+47
-8
forumComplaintService.js
app/service/forumComplaintService.js
+52
-15
No files found.
app/controllers/admin/forumComplaint.js
View file @
742dca0d
...
...
@@ -44,6 +44,18 @@ router.get('/complaints/getComplaints', function(req, res, next) {
});
});
//在获取举报详细
router
.
get
(
'/complaints/:complaintid/detail'
,
function
(
req
,
res
,
next
)
{
var
complaintid
=
req
.
params
.
complaintid
;
ForumComplaintService
.
getDetailByComplaintid
(
complaintid
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
({
result
:
result
},
returnCode
.
SUCCESS
));
}
});
});
//删除黑名单根据id
router
.
get
(
'/complaints/:id/del'
,
function
(
req
,
res
,
next
)
{
var
id
=
req
.
params
.
id
;
...
...
app/controllers/admin/forumThread.js
View file @
742dca0d
...
...
@@ -30,7 +30,9 @@ router.post('/thread/create', function(req, res, next) {
var
rs
=
{};
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='12345';
if
(
req
.
body
.
pid
)
{
...
...
@@ -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) {
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
rs
.
data
=
results
[
0
];
rs
.
tagList
=
results
[
1
];
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
if
(
results
[
0
].
pid
)
{
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
{
...
...
@@ -210,6 +225,7 @@ router.get('/threads/list', function(req, res, next) {
var
infoId
=
req
.
query
.
infoId
;
var
tagId
=
req
.
query
.
tagId
;
var
pid
=
req
.
query
.
pid
;
var
content
=
req
.
query
.
content
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
level
:
1
...
...
@@ -228,12 +244,28 @@ router.get('/threads/list', function(req, res, next) {
conditions
.
level
=
2
;
}
if
(
content
)
{
conditions
.
content
=
{
$regex
:
content
,
$options
:
'i'
}
}
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
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
));
}
}
});
});
...
...
@@ -364,7 +396,14 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
});
// 更新评论对象
// 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
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -473,7 +512,7 @@ router.post('/thread/comment/add', function(req, res, next) {
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
// 测试环境
// entity.from = '55015675868b65a028187c49';
...
...
app/service/forumComplaintService.js
View file @
742dca0d
...
...
@@ -19,28 +19,54 @@ exports.getForumComplaintPageList=function(condition,pageNo,pageSize,callback){
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
skip
=
skip
>
0
?
skip
:
0
;
var
limit
=
pageSize
;
ForumComplaint
.
find
(
_condition
)
.
populate
(
'complaintTo'
).
populate
(
'complaintFrom'
).
limit
(
limit
)
.
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
complaints
){
ForumComplaint
.
distinct
(
'complaintId'
,
_condition
)
.
exec
(
function
(
err
,
complaints
)
{
if
(
err
){
console
.
error
(
err
);
return
callback
&&
callback
(
err
,
null
);
}
obj
.
total
=
count
;
if
(
!
complaints
||
complaints
.
length
<=
0
){
return
callback
&&
callback
(
null
,
obj
);
}
obj
.
total
=
count
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
complaints
;
return
callback
&&
callback
(
null
,
obj
);
var
real_items
=
complaints
.
slice
(
skip
,
skip
+
limit
);
var
tasks
=
[];
var
pushTask
=
function
(
i
){
var
con
=
{
complaintId
:
real_items
[
i
]};
tasks
.
push
(
function
(
cb
){
ForumComplaint
.
find
(
con
)
.
populate
(
'complaintTo'
).
exec
(
function
(
err
,
complaints
){
if
(
!
err
&&
complaints
&&
complaints
.
length
>
0
){
var
complaint
=
complaints
[
0
];
if
(
complaint
&&
'function'
===
typeof
complaint
.
toObject
){
complaint
=
complaint
.
toObject
();
}
complaint
.
sum
=
complaints
.
length
;
cb
(
null
,
complaint
);
}
});
});
};
for
(
var
i
=
0
,
len
=
real_items
.
length
;
i
<
len
;
i
=
i
+
1
){
pushTask
(
i
);
}
async
.
parallel
(
tasks
,
function
(
err
,
results
)
{
obj
.
items
=
results
||
[];
return
callback
&&
callback
(
null
,
obj
);
});
});
};
ForumComplaint
.
count
(
_condition
,
function
(
err
,
coun
t
)
{
if
(
err
){
return
callback
&&
callback
(
err
,
null
);
}
if
(
!!!
count
){
return
callback
&&
callback
(
null
,
obj
);
}
return
search
(
count
);
ForumComplaint
.
distinct
(
'complaintId'
,
_condition
).
exec
(
function
(
err
,
resul
t
)
{
if
(
err
){
return
callback
&&
callback
(
err
,
null
);
}
if
(
!
result
||
result
.
length
<=
0
){
return
callback
&&
callback
(
null
,
obj
);
}
return
search
(
result
.
length
);
});
};
...
...
@@ -142,4 +168,15 @@ exports.removeComplaintById = function(id,callback){
}
return
callback
&&
callback
(
null
,
result
);
});
}
\ No newline at end of file
};
exports
.
getDetailByComplaintid
=
function
(
complaintid
,
callback
){
ForumComplaint
.
find
({
complaintId
:
complaintid
})
.
populate
(
'complaintTo'
).
populate
(
'complaintFrom'
)
.
exec
(
function
(
err
,
complaints
){
if
(
err
)
{
return
callback
&&
callback
(
err
,
null
);
}
return
callback
&&
callback
(
null
,
complaints
);
});
};
\ 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