This commit is contained in:
payacom
2026-09-13 21:32:36 +03:30
parent 90c5f94b57
commit c302aea177
49 changed files with 4063 additions and 920 deletions

View File

@@ -0,0 +1,39 @@
const AuditLog = require('../../../models/AuditLogModel')
const AdminModel = require('../../../models/AdminModel')
const listAuditLog = async (req, res, next) => {
try {
const page = Math.max(parseInt(req.query.page, 10) || 1, 1)
const limit = Math.min(parseInt(req.query.limit, 10) || 30, 100)
const filter = {}
if (req.query.adminId) filter.adminId = req.query.adminId
const [logs, total] = await Promise.all([
AuditLog.find(filter)
.sort({ createdAt: -1 })
.skip((page - 1) * limit)
.limit(limit)
.lean(),
AuditLog.countDocuments(filter)
])
res.status(200).json({
logs,
totalPages: Math.ceil(total / limit) || 1,
totalItems: total
})
} catch (error) {
next(error)
}
}
const listAdminsForFilter = async (req, res, next) => {
try {
const admins = await AdminModel.find({}).select('user_name first_name last_name').lean()
res.status(200).json({ admins })
} catch (error) {
next(error)
}
}
module.exports = { listAuditLog, listAdminsForFilter }