feat(f4): expose INF editing, GEDO and follow-up endpoints
This commit is contained in:
@@ -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 { CurrentAuth } from '../auth/decorators/current-auth.decorator';
|
||||||
import { RequirePermissions } from '../authorization/decorators/require-permissions.decorator';
|
import { RequirePermissions } from '../authorization/decorators/require-permissions.decorator';
|
||||||
import type { Response } from 'express';
|
import type { Response } from 'express';
|
||||||
import type { AuthPrincipal, RequestWithContext } from '../common/http/request-context';
|
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 { 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 { InspectionReportsService } from './inspection-reports.service';
|
||||||
import { InspectionReportWordService } from './inspection-report-word.service';
|
import { InspectionReportWordService } from './inspection-report-word.service';
|
||||||
|
|
||||||
@Controller('inspection-reports')
|
@Controller('inspection-reports')
|
||||||
export class InspectionReportsController {
|
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()
|
@Get()
|
||||||
@RequirePermissions('inspection_reports.read')
|
@RequirePermissions('inspection_reports.read')
|
||||||
@@ -42,6 +68,53 @@ export class InspectionReportsController {
|
|||||||
return response.sendFile(content.filePath);
|
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')
|
@Get(':id')
|
||||||
@RequirePermissions('inspection_reports.read')
|
@RequirePermissions('inspection_reports.read')
|
||||||
get(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
|
get(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user