mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 07:38:10 +00:00
Backoffice UAT results addressed, packages and other updates
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Body, Controller, Get, Param, Patch, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { Body, Controller, Delete, Get, Param, Patch, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { IsInt, IsPositive, IsString } from 'class-validator';
|
||||
import { ExcessBaggageService } from './excess-baggage.service';
|
||||
import {
|
||||
LogExcessBaggageDto,
|
||||
@@ -8,6 +9,13 @@ import {
|
||||
} from './excess-baggage.dto';
|
||||
import { JwtGuard as IamJwtGuard } from '@tria-plc/api-common/modules/auth/services/jwt.guard';
|
||||
|
||||
class UpsertBaggageAllowanceDto {
|
||||
@IsString() seatClassId: string;
|
||||
@IsInt() @IsPositive() maxWeightKg: number;
|
||||
@IsInt() @IsPositive() maxPiecesCount: number;
|
||||
@IsInt() @IsPositive() excessFeePerKg: number;
|
||||
}
|
||||
|
||||
// ── IAM-protected agent/supervisor routes ────────────────────────────────────
|
||||
@ApiTags('Excess Baggage')
|
||||
@Controller('agents/excess-baggage')
|
||||
@@ -55,6 +63,30 @@ export class ExcessBaggageAgentController {
|
||||
waiveCharge(@Param('id') id: string, @Body() dto: WaiveChargeDto) {
|
||||
return this.service.waiveCharge(id, dto);
|
||||
}
|
||||
|
||||
@Get('allowances')
|
||||
@ApiOperation({ summary: 'List all baggage allowance rules' })
|
||||
getAllowances() {
|
||||
return this.service.getAllowances();
|
||||
}
|
||||
|
||||
@Post('allowances')
|
||||
@ApiOperation({ summary: 'Create baggage allowance rule for a seat class' })
|
||||
createAllowance(@Body() dto: UpsertBaggageAllowanceDto) {
|
||||
return this.service.upsertAllowance(dto);
|
||||
}
|
||||
|
||||
@Patch('allowances/:id')
|
||||
@ApiOperation({ summary: 'Update baggage allowance rule' })
|
||||
updateAllowance(@Param('id') id: string, @Body() dto: Partial<UpsertBaggageAllowanceDto>) {
|
||||
return this.service.updateAllowance(id, dto);
|
||||
}
|
||||
|
||||
@Delete('allowances/:id')
|
||||
@ApiOperation({ summary: 'Delete baggage allowance rule' })
|
||||
deleteAllowance(@Param('id') id: string) {
|
||||
return this.service.deleteAllowance(id);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Public pay-by-token routes (passenger self-service) ──────────────────────
|
||||
|
||||
@@ -249,4 +249,30 @@ export class ExcessBaggageService {
|
||||
|
||||
return { items, total, page, pageSize };
|
||||
}
|
||||
|
||||
async getAllowances() {
|
||||
const [allowances, seatClasses] = await Promise.all([
|
||||
this.prisma.baggageAllowance.findMany({ orderBy: { createdAt: 'asc' } }),
|
||||
this.prisma.seatClass.findMany({ select: { id: true, name: true } }),
|
||||
]);
|
||||
const scMap = new Map(seatClasses.map(s => [s.id, s]));
|
||||
return allowances.map(a => ({ ...a, seatClass: scMap.get(a.seatClassId) ?? null }));
|
||||
}
|
||||
|
||||
async upsertAllowance(dto: { seatClassId: string; maxWeightKg: number; maxPiecesCount: number; excessFeePerKg: number }) {
|
||||
return this.prisma.baggageAllowance.upsert({
|
||||
where: { seatClassId: dto.seatClassId } as any,
|
||||
update: { maxWeightKg: dto.maxWeightKg, maxPiecesCount: dto.maxPiecesCount, excessFeePerKg: dto.excessFeePerKg },
|
||||
create: { seatClassId: dto.seatClassId, maxWeightKg: dto.maxWeightKg, maxPiecesCount: dto.maxPiecesCount, excessFeePerKg: dto.excessFeePerKg },
|
||||
});
|
||||
}
|
||||
|
||||
async updateAllowance(id: string, dto: Partial<{ maxWeightKg: number; maxPiecesCount: number; excessFeePerKg: number }>) {
|
||||
return this.prisma.baggageAllowance.update({ where: { id }, data: dto });
|
||||
}
|
||||
|
||||
async deleteAllowance(id: string) {
|
||||
await this.prisma.baggageAllowance.delete({ where: { id } });
|
||||
return { deleted: true };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user