mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Param,
|
|
ParseUUIDPipe,
|
|
Patch,
|
|
Post,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { FleetManage, FleetView } from '../../common/booking-guards';
|
|
import { FREIGHT_PERMS } from '../../seed/freight-permissions.registry';
|
|
import { CreateContainerDto } from './dto/create-container.dto';
|
|
import { UpdateContainerDto } from './dto/update-container.dto';
|
|
import { AssignContainerToWagonDto } from './dto/assign-container-to-wagon.dto';
|
|
import { ContainersService } from './containers.service';
|
|
|
|
@ApiTags('containers')
|
|
@Controller('containers')
|
|
@FleetView(FREIGHT_PERMS.containers.view)
|
|
export class ContainersController {
|
|
constructor(private readonly containersService: ContainersService) {}
|
|
|
|
@Post()
|
|
@FleetManage(FREIGHT_PERMS.containers.create)
|
|
@ApiOperation({ summary: 'Create a new container' })
|
|
create(@Body() dto: CreateContainerDto) {
|
|
return this.containersService.create(dto);
|
|
}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'List all containers' })
|
|
findAll(@Query() query: Record<string, string | undefined>) {
|
|
return this.containersService.findAll(query);
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: 'Get a container by ID' })
|
|
findOne(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.containersService.findById(id);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@FleetManage(FREIGHT_PERMS.containers.update)
|
|
@ApiOperation({ summary: 'Update a container' })
|
|
update(@Param('id', ParseUUIDPipe) id: string, @Body() dto: UpdateContainerDto) {
|
|
return this.containersService.update(id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@FleetManage(FREIGHT_PERMS.containers.delete)
|
|
@ApiOperation({ summary: 'Delete a container' })
|
|
remove(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.containersService.remove(id);
|
|
}
|
|
|
|
@Post(':id/assign-wagon')
|
|
@FleetManage(FREIGHT_PERMS.containers.update)
|
|
@ApiOperation({ summary: 'Assign container to a wagon' })
|
|
assignToWagon(@Param('id', ParseUUIDPipe) id: string, @Body() dto: AssignContainerToWagonDto) {
|
|
return this.containersService.assignToWagon(id, dto);
|
|
}
|
|
|
|
@Post(':id/unassign-wagon')
|
|
@FleetManage(FREIGHT_PERMS.containers.update)
|
|
@ApiOperation({ summary: 'Unassign container from wagon' })
|
|
unassignFromWagon(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.containersService.unassignFromWagon(id);
|
|
}
|
|
}
|