mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 22:18:12 +00:00
user permition
This commit is contained in:
@@ -14,7 +14,8 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import { TrainSchedulingManage, TrainSchedulingView } from '../../common/booking-guards';
|
||||
import { BookingStaff } from '../../common/booking-guards';
|
||||
import { FREIGHT_PERMS } from '../../seed/freight-permissions.registry';
|
||||
|
||||
import { CreateFirstMileDto } from './dto/create-first-mile.dto';
|
||||
import { UpdateFirstMileDto } from './dto/update-first-mile.dto';
|
||||
@@ -27,7 +28,7 @@ import { FirstMileInvoiceService } from './first-mile-invoice.service';
|
||||
@ApiTags('first-mile')
|
||||
@ApiBearerAuth()
|
||||
@Controller('first-mile')
|
||||
@TrainSchedulingView()
|
||||
@BookingStaff(FREIGHT_PERMS.firstMile.view)
|
||||
export class FirstMileController {
|
||||
constructor(
|
||||
private readonly firstMileService: FirstMileService,
|
||||
@@ -63,27 +64,28 @@ export class FirstMileController {
|
||||
}
|
||||
|
||||
@Get('acceptitem/:id')
|
||||
@BookingStaff(FREIGHT_PERMS.firstMile.accept)
|
||||
@ApiOperation({ summary: 'Get a first-mile accep by ID' })
|
||||
acceptItem(@Param('id', ParseUUIDPipe) id: string) {
|
||||
return this.firstMileService.acceptBooking(id);
|
||||
}
|
||||
|
||||
@Post('accept/:reference')
|
||||
@TrainSchedulingManage()
|
||||
@BookingStaff(FREIGHT_PERMS.firstMile.accept)
|
||||
@ApiOperation({ summary: 'Accept a paid booking and create a first-mile leg' })
|
||||
acceptBooking(@Param('reference') reference: string) {
|
||||
return this.firstMileService.acceptBookingByReference(reference);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@TrainSchedulingManage()
|
||||
@BookingStaff(FREIGHT_PERMS.firstMile.create)
|
||||
@ApiOperation({ summary: 'Create a first-mile leg' })
|
||||
create(@Body() dto: CreateFirstMileDto) {
|
||||
return this.firstMileService.create(dto);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@TrainSchedulingManage()
|
||||
@BookingStaff(FREIGHT_PERMS.firstMile.update)
|
||||
@ApiOperation({ summary: 'Update a first-mile leg' })
|
||||
async update(@Param('id', ParseUUIDPipe) id: string, @Body() dto: UpdateFirstMileDto) {
|
||||
// No invoice side-effects — invoices are generated only via the explicit
|
||||
@@ -92,7 +94,7 @@ export class FirstMileController {
|
||||
}
|
||||
|
||||
@Post(':id/invoice')
|
||||
@TrainSchedulingManage()
|
||||
@BookingStaff(FREIGHT_PERMS.firstMile.generateInvoice)
|
||||
@ApiOperation({ summary: 'Generate the first-mile delivery-fee invoice' })
|
||||
async generateInvoice(@Param('id', ParseUUIDPipe) id: string) {
|
||||
const record = await this.firstMileService.findById(id);
|
||||
@@ -106,7 +108,7 @@ export class FirstMileController {
|
||||
}
|
||||
|
||||
@Post(':id/vehicles')
|
||||
@TrainSchedulingManage()
|
||||
@BookingStaff(FREIGHT_PERMS.firstMile.assignVehicles)
|
||||
@ApiOperation({ summary: 'Set the vehicles assigned to a first-mile pickup (multi-truck)' })
|
||||
async setVehicles(
|
||||
@Param('id', ParseUUIDPipe) id: string,
|
||||
@@ -116,7 +118,7 @@ export class FirstMileController {
|
||||
}
|
||||
|
||||
@Post(':id/distances')
|
||||
@TrainSchedulingManage()
|
||||
@BookingStaff(FREIGHT_PERMS.firstMile.setDistances)
|
||||
@ApiOperation({ summary: 'Set per-vehicle actual distances (does not generate an invoice)' })
|
||||
async setDistances(
|
||||
@Param('id', ParseUUIDPipe) id: string,
|
||||
@@ -126,7 +128,7 @@ export class FirstMileController {
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@TrainSchedulingManage()
|
||||
@BookingStaff(FREIGHT_PERMS.firstMile.delete)
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@ApiOperation({ summary: 'Soft-delete a first-mile leg' })
|
||||
remove(@Param('id', ParseUUIDPipe) id: string) {
|
||||
|
||||
Reference in New Issue
Block a user