mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 09:00:57 +00:00
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, ParseUUIDPipe, Patch, Post, Query } from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
|
|
import { FleetManage, FleetView } from '../../common/booking-guards';
|
|
import { FREIGHT_PERMS } from '../../seed/freight-permissions.registry';
|
|
import { CreateRouteDto } from './dto/create-route.dto';
|
|
import { FilterRoutesDto } from './dto/filter-routes.dto';
|
|
import { UpdateRouteDto } from './dto/update-route.dto';
|
|
import { RoutesService } from './routes.service';
|
|
|
|
@ApiTags('routes')
|
|
@ApiBearerAuth()
|
|
@Controller('routes')
|
|
@FleetView(FREIGHT_PERMS.routes.view)
|
|
export class RoutesController {
|
|
constructor(private readonly routesService: RoutesService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'List routes' })
|
|
findAll(@Query() filter: FilterRoutesDto) {
|
|
return this.routesService.findAll(filter);
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: 'Get route by ID' })
|
|
findOne(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.routesService.findById(id);
|
|
}
|
|
|
|
@Post()
|
|
@FleetManage(FREIGHT_PERMS.routes.create)
|
|
@ApiOperation({ summary: 'Create route' })
|
|
create(@Body() dto: CreateRouteDto) {
|
|
return this.routesService.create(dto);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@FleetManage(FREIGHT_PERMS.routes.update)
|
|
@ApiOperation({ summary: 'Update route' })
|
|
update(@Param('id', ParseUUIDPipe) id: string, @Body() dto: UpdateRouteDto) {
|
|
return this.routesService.update(id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@FleetManage(FREIGHT_PERMS.routes.delete)
|
|
@ApiOperation({ summary: 'Deactivate route' })
|
|
remove(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.routesService.deactivate(id);
|
|
}
|
|
}
|