chore: import DH V2 D5.6.4 production baseline
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import { Controller, Get, Param, ParseUUIDPipe, Post, Query, Req, Res } from '@nestjs/common';
|
||||
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 { ListInspectionReportsQueryDto } from './dto/list-inspection-reports-query.dto';
|
||||
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) {}
|
||||
|
||||
@Get()
|
||||
@RequirePermissions('inspection_reports.read')
|
||||
list(@Query() query: ListInspectionReportsQueryDto) {
|
||||
return this.reports.list(query);
|
||||
}
|
||||
|
||||
@Get('pending')
|
||||
@RequirePermissions('inspection_reports.read')
|
||||
pending(@Query() query: ListInspectionReportsQueryDto) {
|
||||
return this.reports.listPending(query);
|
||||
}
|
||||
|
||||
@Post(':id/word')
|
||||
@RequirePermissions('inspection_reports.generate')
|
||||
async generateWord(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
|
||||
await this.word.ensure(id);
|
||||
return this.reports.get(id);
|
||||
}
|
||||
|
||||
@Get(':id/word')
|
||||
@RequirePermissions('inspection_reports.read')
|
||||
async wordContent(
|
||||
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
|
||||
@Res() response: Response,
|
||||
) {
|
||||
const content = await this.word.content(id);
|
||||
response.setHeader('Content-Type', content.mimeType);
|
||||
response.setHeader('Content-Disposition', `attachment; filename="${content.originalName.replaceAll('"', '')}"`);
|
||||
return response.sendFile(content.filePath);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@RequirePermissions('inspection_reports.read')
|
||||
get(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
|
||||
return this.reports.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('inspection-acts/:actId/report')
|
||||
export class InspectionActReportController {
|
||||
constructor(private readonly reports: InspectionReportsService) {}
|
||||
|
||||
@Post()
|
||||
@RequirePermissions('inspection_reports.generate')
|
||||
generate(
|
||||
@Param('actId', new ParseUUIDPipe({ version: '4' })) actId: string,
|
||||
@CurrentAuth() principal: AuthPrincipal,
|
||||
@Req() request: RequestWithContext,
|
||||
) {
|
||||
return this.reports.generate(actId, principal, request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user