mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import {
|
|
Body, Controller, Delete, Get, HttpCode, HttpStatus,
|
|
Param, ParseUUIDPipe, Patch, Post, Query,
|
|
} from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { CreatePriorityRuleDto } from '../dto/create-priority-rule.dto';
|
|
import { UpdatePriorityRuleDto } from '../dto/update-priority-rule.dto';
|
|
import { PriorityRulesService } from '../services/priority-rules.service';
|
|
|
|
@ApiTags('priority-rules')
|
|
@Controller('priority-rules')
|
|
// @UseGuards(JwtAuthGuard) — TODO: add when auth package integrated
|
|
@ApiBearerAuth()
|
|
export class PriorityRulesController {
|
|
constructor(private readonly service: PriorityRulesService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'List priority rules' })
|
|
findAll(@Query() query: Record<string, string>) {
|
|
return this.service.findAll({
|
|
isActive: query['isActive'] !== undefined ? query['isActive'] === 'true' : undefined,
|
|
page: query['page'] ? parseInt(query['page'], 10) : undefined,
|
|
pageSize: query['pageSize'] ? parseInt(query['pageSize'], 10) : undefined,
|
|
});
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: 'Get a priority rule by ID' })
|
|
findOne(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.service.findById(id);
|
|
}
|
|
|
|
@Post()
|
|
@ApiOperation({ summary: 'Create a priority rule' })
|
|
create(@Body() dto: CreatePriorityRuleDto) {
|
|
return this.service.create(dto);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@ApiOperation({ summary: 'Update a priority rule' })
|
|
update(@Param('id', ParseUUIDPipe) id: string, @Body() dto: UpdatePriorityRuleDto) {
|
|
return this.service.update(id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@ApiOperation({ summary: 'Soft-delete a priority rule' })
|
|
remove(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.service.remove(id);
|
|
}
|
|
}
|