Files
edr-platform/apps/edr-freight-api/src/modules/interchange-documents/interchange-documents.controller.ts
hagiye f4a90755c2 api
2026-06-25 11:00:40 +03:00

57 lines
2.0 KiB
TypeScript

import { Body, Controller, Get, Param, ParseUUIDPipe, Patch, Post, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { GenerateFromScheduleDto } from './dto/generate-from-schedule.dto';
import { InterchangeDocumentQueryDto } from './dto/interchange-document-query.dto';
import {
AcknowledgeInterchangeDocumentDto,
DisputeInterchangeDocumentDto,
} from './dto/update-interchange-document-status.dto';
import { InterchangeDocumentsService } from './interchange-documents.service';
@ApiTags('interchange-documents')
@ApiBearerAuth()
@Controller('interchange-documents')
export class InterchangeDocumentsController {
constructor(private readonly service: InterchangeDocumentsService) {}
@Get()
@ApiOperation({ summary: 'List interchange documents' })
findAll(@Query() query: InterchangeDocumentQueryDto) {
return this.service.findAll(query);
}
@Get(':id')
@ApiOperation({ summary: 'Get interchange document detail' })
findOne(@Param('id', ParseUUIDPipe) id: string) {
return this.service.findOne(id);
}
@Post('generate-from-schedule')
@ApiOperation({ summary: 'Generate interchange document from a train schedule handover' })
generateFromSchedule(@Body() dto: GenerateFromScheduleDto) {
return this.service.generateFromSchedule(dto);
}
@Patch(':id/acknowledge')
@ApiOperation({ summary: 'Acknowledge an interchange document' })
acknowledge(
@Param('id', ParseUUIDPipe) id: string,
@Body() dto: AcknowledgeInterchangeDocumentDto,
) {
return this.service.acknowledge(id, dto);
}
@Patch(':id/dispute')
@ApiOperation({ summary: 'Dispute an interchange document' })
dispute(@Param('id', ParseUUIDPipe) id: string, @Body() dto: DisputeInterchangeDocumentDto) {
return this.service.dispute(id, dto);
}
@Patch(':id/cancel')
@ApiOperation({ summary: 'Cancel a draft/generated interchange document' })
cancel(@Param('id', ParseUUIDPipe) id: string) {
return this.service.cancel(id);
}
}