import { Body, Controller, Get, Param, ParseUUIDPipe, 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 { ConsignmentsService } from "./consignments.service"; import { CreateConsignmentDto } from "./dto/create-consignment.dto"; import { FilterConsignmentDto } from "./dto/filter-consignment.dto"; @ApiTags("consignments") @Controller("consignments") // Class gate lists every key its routes use: Nest runs class AND method // guards, so a key missing here would deny before the route's own key runs. @FleetView([ FREIGHT_PERMS.consignments.view, FREIGHT_PERMS.consignments.create, ]) export class ConsignmentsController { constructor(private readonly consignmentsService: ConsignmentsService) {} @Post() @FleetManage(FREIGHT_PERMS.consignments.create) @ApiOperation({ summary: "Create a new consignment" }) create(@Body() dto: CreateConsignmentDto) { return this.consignmentsService.create(dto); } @Get() @ApiOperation({ summary: "List consignments (paginated)" }) findAll(@Query() filter: FilterConsignmentDto) { return this.consignmentsService.findAll(filter); } @Get(":id") @ApiOperation({ summary: "Get a consignment by ID" }) findOne(@Param("id", ParseUUIDPipe) id: string) { return this.consignmentsService.findById(id); } }