mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Param,
|
|
ParseUUIDPipe,
|
|
Patch,
|
|
Post,
|
|
} from '@nestjs/common';
|
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { CreateCargoDto } from './dto/create-cargo.dto';
|
|
import { UpdateCargoDto } from './dto/update-cargo.dto';
|
|
import { LoadCargoDto } from './dto/load-cargo.dto';
|
|
import { DeliverCargoDto } from './dto/deliver-cargo.dto';
|
|
import { CargoesService } from './cargoes.service';
|
|
|
|
@ApiTags('cargoes')
|
|
@Controller('cargoes')
|
|
export class CargoesController {
|
|
constructor(private readonly cargoesService: CargoesService) {}
|
|
|
|
@Post()
|
|
@ApiOperation({ summary: 'Create a new cargo' })
|
|
create(@Body() dto: CreateCargoDto) {
|
|
return this.cargoesService.create(dto);
|
|
}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'List all cargoes' })
|
|
findAll() {
|
|
return this.cargoesService.findAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: 'Get a cargo by ID' })
|
|
findOne(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.cargoesService.findById(id);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@ApiOperation({ summary: 'Update a cargo' })
|
|
update(@Param('id', ParseUUIDPipe) id: string, @Body() dto: UpdateCargoDto) {
|
|
return this.cargoesService.update(id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@ApiOperation({ summary: 'Delete a cargo' })
|
|
remove(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.cargoesService.remove(id);
|
|
}
|
|
|
|
@Post(':id/load')
|
|
@ApiOperation({ summary: 'Load cargo into a container' })
|
|
load(@Param('id', ParseUUIDPipe) id: string, @Body() dto: LoadCargoDto) {
|
|
return this.cargoesService.loadCargo(id, dto);
|
|
}
|
|
|
|
@Post(':id/unload')
|
|
@ApiOperation({ summary: 'Unload cargo from container' })
|
|
unload(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.cargoesService.unloadCargo(id);
|
|
}
|
|
|
|
@Post(':id/deliver')
|
|
@ApiOperation({ summary: 'Mark cargo as delivered' })
|
|
deliver(@Param('id', ParseUUIDPipe) id: string, @Body() dto?: DeliverCargoDto) {
|
|
return this.cargoesService.deliverCargo(id, dto);
|
|
}
|
|
} |