From 39846c81a483d2b62bdcad2f887bff8be846a06c Mon Sep 17 00:00:00 2001 From: enlineawork Date: Mon, 7 Sep 2026 20:57:37 -0300 Subject: [PATCH] feat(f4): expose INF editing, GEDO and follow-up endpoints --- .../inspection-reports.controller.ts | 77 ++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/api-v3/src/inspection-reports/inspection-reports.controller.ts b/api-v3/src/inspection-reports/inspection-reports.controller.ts index 536a543..3f44101 100644 --- a/api-v3/src/inspection-reports/inspection-reports.controller.ts +++ b/api-v3/src/inspection-reports/inspection-reports.controller.ts @@ -1,15 +1,41 @@ -import { Controller, Get, Param, ParseUUIDPipe, Post, Query, Req, Res } from '@nestjs/common'; +import { + Body, + Controller, + Get, + Param, + ParseUUIDPipe, + Patch, + Post, + Query, + Req, + Res, + UploadedFile, + UseInterceptors, +} from '@nestjs/common'; +import { FileInterceptor } from '@nestjs/platform-express'; import { CurrentAuth } from '../auth/decorators/current-auth.decorator'; import { RequirePermissions } from '../authorization/decorators/require-permissions.decorator'; import type { Response } from 'express'; import type { AuthPrincipal, RequestWithContext } from '../common/http/request-context'; +import { CreateInspectionReportFollowUpDto } from './dto/create-inspection-report-follow-up.dto'; import { ListInspectionReportsQueryDto } from './dto/list-inspection-reports-query.dto'; +import { OfficializeInspectionReportDto } from './dto/officialize-inspection-report.dto'; +import { UpdateInspectionReportDto } from './dto/update-inspection-report.dto'; +import { + InspectionReportWorkflowService, + MAX_INSPECTION_REPORT_FILE_BYTES, + type UploadedInspectionReportFile, +} from './inspection-report-workflow.service'; import { InspectionReportsService } from './inspection-reports.service'; import { InspectionReportWordService } from './inspection-report-word.service'; @Controller('inspection-reports') export class InspectionReportsController { - constructor(private readonly reports: InspectionReportsService, private readonly word: InspectionReportWordService) {} + constructor( + private readonly reports: InspectionReportsService, + private readonly word: InspectionReportWordService, + private readonly workflow: InspectionReportWorkflowService, + ) {} @Get() @RequirePermissions('inspection_reports.read') @@ -42,6 +68,53 @@ export class InspectionReportsController { return response.sendFile(content.filePath); } + @Patch(':id') + @RequirePermissions('inspection_reports.generate') + updateNarrative( + @Param('id', new ParseUUIDPipe({ version: '4' })) id: string, + @Body() dto: UpdateInspectionReportDto, + @CurrentAuth() principal: AuthPrincipal, + @Req() request: RequestWithContext, + ) { + return this.workflow.updateNarrative(id, dto, principal, request); + } + + @Post(':id/officialize') + @RequirePermissions('inspection_reports.generate') + @UseInterceptors(FileInterceptor('file', { + limits: { fileSize: MAX_INSPECTION_REPORT_FILE_BYTES, files: 1 }, + })) + officialize( + @Param('id', new ParseUUIDPipe({ version: '4' })) id: string, + @Body() dto: OfficializeInspectionReportDto, + @UploadedFile() file: UploadedInspectionReportFile | undefined, + @CurrentAuth() principal: AuthPrincipal, + @Req() request: RequestWithContext, + ) { + return this.workflow.officialize(id, dto, file, principal, request); + } + + @Get(':id/follow-ups') + @RequirePermissions('inspection_reports.read') + followUps(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) { + return this.workflow.listFollowUps(id); + } + + @Post(':id/follow-ups') + @RequirePermissions('inspection_reports.generate') + @UseInterceptors(FileInterceptor('file', { + limits: { fileSize: MAX_INSPECTION_REPORT_FILE_BYTES, files: 1 }, + })) + addFollowUp( + @Param('id', new ParseUUIDPipe({ version: '4' })) id: string, + @Body() dto: CreateInspectionReportFollowUpDto, + @UploadedFile() file: UploadedInspectionReportFile | undefined, + @CurrentAuth() principal: AuthPrincipal, + @Req() request: RequestWithContext, + ) { + return this.workflow.addFollowUp(id, dto, file, principal, request); + } + @Get(':id') @RequirePermissions('inspection_reports.read') get(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {