import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common';
import { AdminAuditLogService } from './admin-audit-log.service';
import { QueryAuditLogsDto } from './dto/query-audit-logs.dto';
import { AdminAuthGuard } from '../../common/guards/admin-auth.guard';
import { AdminRolesGuard } from '../../common/guards/admin-roles.guard';
import { AdminRoles } from '../../common/decorators/admin-roles.decorator';
import { AdminRole } from '../../common/types/admin-role.enum';

@ApiTags('admin-audit-log')
@Controller('admin-api/audit-logs')
@UseGuards(AdminAuthGuard, AdminRolesGuard)
@AdminRoles(AdminRole.ADMIN)
export class AdminAuditLogController {
  constructor(private readonly auditLogService: AdminAuditLogService) {}

  @Get()
  @ApiBearerAuth()
  @ApiOperation({ summary: '获取审计日志列表' })
  async list(@Query() query: QueryAuditLogsDto) {
    return this.auditLogService.list(query);
  }

  @Get(':id')
  @ApiBearerAuth()
  @ApiOperation({ summary: '获取审计日志详情' })
  async getById(@Param('id') id: string) {
    return this.auditLogService.getById(id);
  }
}
