mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 02:30:55 +00:00
Apply JwtGuard + FreightPermissionGuard (via @BookingStaff) to 83 staff endpoints across the 8 warehouse controllers, using existing edr_freight_app:warehouse* permissions: warehouses/yards/zones, inventory receive/move/load/unload/dispatch/gate-pass/release/deliver/inspect (incl. import & export queues), allocation + fee rules (demurrage/storage/ double-handling), accrual dashboard + acknowledge, and fee invoices. Customer-portal endpoints (booking-scoped documents, approve-delivery, portal fee-invoice view/document/receipt/pay-online) are intentionally left unguarded — they need a customer-ownership guard, not staff permissions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
75 lines
2.7 KiB
TypeScript
75 lines
2.7 KiB
TypeScript
import { Body, Controller, Get, Param, ParseUUIDPipe, Patch, Post, Query } from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
|
|
import { BookingStaff } from '../../common/booking-guards';
|
|
import { FREIGHT_PERMS } from '../../seed/freight-permissions.registry';
|
|
import { CreateWarehouseDto } from './dto/create-warehouse.dto';
|
|
import { CreateWarehouseYardDto } from './dto/create-warehouse-yard.dto';
|
|
import { FilterWarehouseDto } from './dto/filter-warehouse.dto';
|
|
import { UpdateWarehouseDto } from './dto/update-warehouse.dto';
|
|
import { WarehouseDashboardService } from './warehouse-dashboard.service';
|
|
import { WarehouseYardsService } from './warehouse-yards.service';
|
|
import { WarehousesService } from './warehouses.service';
|
|
|
|
@ApiTags('warehouses')
|
|
@ApiBearerAuth()
|
|
@Controller('warehouses')
|
|
@BookingStaff(FREIGHT_PERMS.warehouses.view)
|
|
export class WarehousesController {
|
|
constructor(
|
|
private readonly warehousesService: WarehousesService,
|
|
private readonly yardsService: WarehouseYardsService,
|
|
private readonly dashboardService: WarehouseDashboardService,
|
|
) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'List warehouses' })
|
|
findAll(@Query() filter: FilterWarehouseDto) {
|
|
return this.warehousesService.findAll(filter);
|
|
}
|
|
|
|
@Get('dashboard')
|
|
@BookingStaff(FREIGHT_PERMS.warehouseDashboard.view)
|
|
@ApiOperation({ summary: 'Warehouse dashboard metrics' })
|
|
dashboard() {
|
|
return this.dashboardService.getDashboard();
|
|
}
|
|
|
|
@Post()
|
|
@BookingStaff(FREIGHT_PERMS.warehouses.create)
|
|
@ApiOperation({ summary: 'Create warehouse' })
|
|
create(@Body() dto: CreateWarehouseDto) {
|
|
return this.warehousesService.create(dto);
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: 'Get warehouse by ID' })
|
|
findOne(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.warehousesService.findById(id);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@BookingStaff(FREIGHT_PERMS.warehouses.update)
|
|
@ApiOperation({ summary: 'Update warehouse' })
|
|
update(@Param('id', ParseUUIDPipe) id: string, @Body() dto: UpdateWarehouseDto) {
|
|
return this.warehousesService.update(id, dto);
|
|
}
|
|
|
|
@Get(':warehouseId/yards')
|
|
@BookingStaff(FREIGHT_PERMS.warehouseYards.view)
|
|
@ApiOperation({ summary: 'List yards within a warehouse' })
|
|
listYards(@Param('warehouseId', ParseUUIDPipe) warehouseId: string) {
|
|
return this.yardsService.findByWarehouse(warehouseId);
|
|
}
|
|
|
|
@Post(':warehouseId/yards')
|
|
@BookingStaff(FREIGHT_PERMS.warehouseYards.create)
|
|
@ApiOperation({ summary: 'Create a yard within a warehouse' })
|
|
createYard(
|
|
@Param('warehouseId', ParseUUIDPipe) warehouseId: string,
|
|
@Body() dto: CreateWarehouseYardDto,
|
|
) {
|
|
return this.yardsService.create(warehouseId, dto);
|
|
}
|
|
}
|