mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 14:08:11 +00:00
Nest runs class and method guards together, so a class gate naming only the view key silently required view AND action. Staff granted just an action were denied before their key was checked. Each class gate now names every key its routes use, and FleetView accepts an array so the fleet controllers keep their coarse fallback. Drops the one-off grant mapping SQL with it: already applied to dev, and this fix removes the companion-view rule that was its recurring part.
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
import { Body, Controller, Get, Param, ParseUUIDPipe, Patch } 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 { UpdateWarehouseZoneDto } from './dto/update-warehouse-zone.dto';
|
|
import { WarehouseZonesService } from './warehouse-zones.service';
|
|
|
|
@ApiTags('warehouse-zones')
|
|
@ApiBearerAuth()
|
|
// Baseline read: zone reference data also serves inventory flows (allocation,
|
|
// receive/move pickers) — either view permission grants reads; writes stack
|
|
// their specific permission per route.
|
|
@Controller('warehouse-zones')
|
|
// 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.
|
|
@BookingStaff([
|
|
FREIGHT_PERMS.warehouseZones.view,
|
|
FREIGHT_PERMS.warehouseInventory.view,
|
|
FREIGHT_PERMS.warehouseZones.update,
|
|
])
|
|
export class WarehouseZonesController {
|
|
constructor(private readonly zonesService: WarehouseZonesService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'List all warehouse zones' })
|
|
findAll() {
|
|
return this.zonesService.findAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: 'Get warehouse zone by ID' })
|
|
findOne(@Param('id', ParseUUIDPipe) id: string) {
|
|
return this.zonesService.findById(id);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@BookingStaff(FREIGHT_PERMS.warehouseZones.update)
|
|
@ApiOperation({ summary: 'Update warehouse zone' })
|
|
update(@Param('id', ParseUUIDPipe) id: string, @Body() dto: UpdateWarehouseZoneDto) {
|
|
return this.zonesService.update(id, dto);
|
|
}
|
|
}
|