feat admin分页
This commit is contained in:
@@ -58,7 +58,8 @@ module.exports = {
|
||||
async getUserActions (req, res) {
|
||||
const { adminId } = res.locals.user;
|
||||
if (!adminId) return res.json({ code: 1, msg: '非法访问' });
|
||||
await Action.find({ ...req.body }).then(data => {
|
||||
const { pageSize = 10, pageIndex = 1 } = req.body;
|
||||
await Action.find({ ...req.body }).limit(pageSize).skip((pageIndex - 1) * pageSize).then(data => {
|
||||
return res.json({
|
||||
code: 0,
|
||||
data
|
||||
@@ -73,7 +74,8 @@ module.exports = {
|
||||
async getDepositTicket (req, res) {
|
||||
const { adminId } = res.locals.user;
|
||||
if (!adminId) return res.json({ code: 1, msg: '非法访问' });
|
||||
await Ticket.find({ ...req.body }).then(data => {
|
||||
const { pageSize = 10, pageIndex = 1} = req.body;
|
||||
await Ticket.find({ ...req.body }).limit(pageSize).skip((pageIndex - 1) * pageSize).then(data => {
|
||||
return res.json({
|
||||
code: 0,
|
||||
data
|
||||
@@ -88,7 +90,9 @@ module.exports = {
|
||||
async getUsers (req, res) {
|
||||
const { adminId } = res.locals.user;
|
||||
if (!adminId) return res.json({ code: 1, msg: '非法访问' });
|
||||
const [sum, data] = await Promise.all([User.count({}), User.find({ ...req.body })]).catch(err => {
|
||||
const { pageSize = 10, pageIndex = 1} = req.body;
|
||||
const [sum, data] = await Promise.all([User.count({}), User.find({ ...req.body }).limit(pageSize).skip((pageIndex - 1) * pageSize)])
|
||||
.catch(err => {
|
||||
return [err.msg, ''];
|
||||
});
|
||||
if (!Array.isArray(data)) return res.json({
|
||||
|
||||
Reference in New Issue
Block a user