import { Body, Controller, Get, Param, Patch, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { AuthUser, CurrentUser } from '../../common/current-user.decorator';
import { RequirePermissions } from '../../common/permissions.decorator';
import { AlarmsService } from './alarms.service';

@ApiBearerAuth()
@ApiTags('报警管理')
@RequirePermissions('alarms:manage')
@Controller('alarms')
export class AlarmsController {
  constructor(private readonly alarmsService: AlarmsService) {}

  @Get()
  findAll(@CurrentUser() user: AuthUser, @Query() query: any) {
    return this.alarmsService.findAll(user, query);
  }

  @Patch(':id/handle')
  handle(@CurrentUser() user: AuthUser, @Param('id') id: string, @Body() dto: any) {
    return this.alarmsService.handle(user, id, dto);
  }
}
