mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { Controller, Get, Param, Query } from '@nestjs/common';
|
|
import { ApiTags, ApiOperation, ApiBearerAuth, ApiQuery } from '@nestjs/swagger';
|
|
import { AuditService } from '../../common/audit.service';
|
|
import { PassengerStaff } from '../../common/passenger-guards';
|
|
import { PASSENGER_PERMS } from '../../seed/passenger-permissions.registry';
|
|
|
|
@ApiTags('Audit')
|
|
@Controller('audit')
|
|
@PassengerStaff([PASSENGER_PERMS.audit.view, PASSENGER_PERMS.admin])
|
|
@ApiBearerAuth('IAM-auth')
|
|
export class AuditController {
|
|
constructor(private auditService: AuditService) {}
|
|
|
|
@Get('logs')
|
|
@ApiOperation({
|
|
summary: 'Get audit logs',
|
|
description: 'Retrieve system audit logs with optional filtering',
|
|
})
|
|
@ApiQuery({ name: 'search', required: false, description: 'Search by user email or entity ID' })
|
|
@ApiQuery({ name: 'action', required: false, description: 'Filter by action (CREATE, UPDATE, DELETE, etc.)' })
|
|
@ApiQuery({ name: 'entityType', required: false, description: 'Filter by entity type (Booking, Station, etc.)' })
|
|
async getLogs(
|
|
@Query('search') search?: string,
|
|
@Query('action') action?: string,
|
|
@Query('entityType') entityType?: string,
|
|
) {
|
|
const filters = {
|
|
search: search || undefined,
|
|
action: action || undefined,
|
|
entityType: entityType || undefined,
|
|
};
|
|
|
|
const items = await this.auditService.getLogs(filters);
|
|
return { items };
|
|
}
|
|
|
|
@Get('logs/:id')
|
|
@ApiOperation({ summary: 'Get audit log by ID' })
|
|
async getLog(@Param('id') id: string) {
|
|
return this.auditService.getLog(id);
|
|
}
|
|
}
|