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
6a5fdb67
Commit
6a5fdb67
authored
Apr 24, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
举报管理
parent
e05f0ffa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
15 deletions
+64
-15
forumComplaint.js
app/controllers/admin/forumComplaint.js
+12
-0
forumComplaintService.js
app/service/forumComplaintService.js
+52
-15
No files found.
app/controllers/admin/forumComplaint.js
View file @
6a5fdb67
...
...
@@ -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/service/forumComplaintService.js
View file @
6a5fdb67
...
...
@@ -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