This commit is contained in:
Baobhan Sith
2025-04-26 15:20:37 +08:00
parent 93b8863fdd
commit e269f40754
80 changed files with 868 additions and 1528 deletions
@@ -39,7 +39,6 @@ export class AuditController {
res.status(400).json({ message: '无效的 endDate 参数' });
return;
}
// TODO: 可以添加对 actionType 是否有效的验证
// 将 searchTerm 传递给 service
const result = await auditLogService.getLogs(limit, offset, actionType, startDate, endDate, searchTerm);
@@ -52,7 +51,7 @@ export class AuditController {
parsedDetails = JSON.parse(log.details);
} catch (e) {
console.warn(`[Audit Log] Failed to parse details for log ID ${log.id}:`, e);
parsedDetails = { raw: log.details, parseError: true }; // 保留原始字符串并标记错误
parsedDetails = { raw: log.details, parseError: true };
}
}
return { ...log, details: parsedDetails };
+2 -3
View File
@@ -1,14 +1,13 @@
import { Router } from 'express';
import { AuditController } from './audit.controller';
import { isAuthenticated } from '../auth/auth.middleware'; // Use the correct auth middleware
import { isAuthenticated } from '../auth/auth.middleware';
const router = Router();
const auditController = new AuditController();
// Apply auth middleware to protect the audit log endpoint
router.use(isAuthenticated);
// Define route for getting audit logs
router.get('/', auditController.getAuditLogs);
export default router;