mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { Body, Controller, Delete, Get, HttpCode, Param, Patch, Post } from '@nestjs/common';
|
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
|
|
import { CreateFacilityDto } from './dto/create-facility.dto';
|
|
import { UpdateFacilityDto } from './dto/update-facility.dto';
|
|
import { Facility } from './entities/facility.entity';
|
|
import { FacilitiesService } from './facilities.service';
|
|
|
|
@ApiTags('Facilities')
|
|
@Controller('facilities')
|
|
export class FacilitiesController {
|
|
constructor(private readonly facilitiesService: FacilitiesService) {}
|
|
|
|
@Post()
|
|
@ApiOperation({ summary: 'Create a new facility' })
|
|
async create(@Body() createFacilityDto: CreateFacilityDto): Promise<Facility> {
|
|
return this.facilitiesService.create(createFacilityDto);
|
|
}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'List all facilities' })
|
|
async findAll(): Promise<Facility[]> {
|
|
return this.facilitiesService.findAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: 'Get a facility by ID' })
|
|
async findOne(@Param('id') id: string): Promise<Facility | null> {
|
|
return this.facilitiesService.findOne(id);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@ApiOperation({ summary: 'Update a facility' })
|
|
async update(@Param('id') id: string, @Body() updateFacilityDto: UpdateFacilityDto): Promise<Facility | null> {
|
|
return this.facilitiesService.update(id, updateFacilityDto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@HttpCode(204)
|
|
@ApiOperation({ summary: 'Delete a facility (soft delete)' })
|
|
async remove(@Param('id') id: string): Promise<void> {
|
|
return this.facilitiesService.remove(id);
|
|
}
|
|
}
|