update the 2 new apis for getting expertise and files of the request

This commit is contained in:
2026-11-11 17:59:48 +03:30
parent 90bdc51715
commit 84b92eb55a
13 changed files with 1111 additions and 195 deletions
@@ -0,0 +1,104 @@
import {
BadRequestException,
Controller,
Get,
Param,
Query,
UseGuards,
} from "@nestjs/common";
import {
ApiBearerAuth,
ApiOperation,
ApiParam,
ApiQuery,
ApiTags,
} from "@nestjs/swagger";
import { LocalActorAuthGuard } from "src/auth/guards/actor-local.guard";
import { CurrentUser } from "src/decorators/user.decorator";
import {
FANAVARAN_CLIENT_SWAGGER_ENUM,
isFanavaranClientKey,
normalizeFanavaranClientKey,
} from "src/core/config/fanavaran-client.config";
import { FanavaranHullReadService } from "./fanavaran-hull-read.service";
@ApiTags("fanavaran")
@ApiBearerAuth()
@UseGuards(LocalActorAuthGuard)
@ApiParam({ name: "client", enum: FANAVARAN_CLIENT_SWAGGER_ENUM })
@ApiParam({
name: "claimCaseId",
description:
"Local claim case MongoDB ObjectId; the saved Fanavaran claimId is used upstream",
})
@Controller("v2/fanavaran/:client/claim-cases/:claimCaseId/hull")
export class FanavaranHullReadController {
constructor(private readonly hull: FanavaranHullReadService) {}
@Get("files")
@ApiOperation({
summary:
"Retrieve submitted hull attachment metadata from Fanavaran (GEN.05)",
description:
"Live file list, including Id, ClaimId, FileName, FileTypeId and Status. The list does not include Base64 Data. Does not depend on locally recorded file IDs.",
})
files(
@Param("client") client: string,
@Param("claimCaseId") claimCaseId: string,
@CurrentUser() actor: any,
) {
return this.hull.files(this.clientKey(client), claimCaseId, actor);
}
@Get("files/:fileId")
@ApiParam({
name: "fileId",
type: Number,
description: "Fanavaran file Id returned by the remote file list",
})
@ApiOperation({
summary: "Retrieve a submitted hull file including Base64 Data (GEN.05)",
})
file(
@Param("client") client: string,
@Param("claimCaseId") claimCaseId: string,
@Param("fileId") fileId: string,
@CurrentUser() actor: any,
) {
return this.hull.file(this.clientKey(client), claimCaseId, fileId, actor);
}
@Get("expertise/dmg-sections")
@ApiQuery({
name: "expertiseId",
required: false,
type: Number,
description:
"Optional historical Fanavaran expertise Id; defaults to the saved expertiseId",
})
@ApiOperation({
summary:
"Retrieve submitted hull expertise damage sections and costs (GEN.12)",
description:
"Reads live damage section IDs, costs, amounts, CINumber and CITrackingCode when supplied by Fanavaran. Does not resubmit expertise.",
})
damageSections(
@Param("client") client: string,
@Param("claimCaseId") claimCaseId: string,
@CurrentUser() actor: any,
@Query("expertiseId") expertiseId?: string,
) {
return this.hull.damageSections(
this.clientKey(client),
claimCaseId,
actor,
expertiseId,
);
}
private clientKey(client: string) {
if (!isFanavaranClientKey(client))
throw new BadRequestException("Invalid Fanavaran client");
return normalizeFanavaranClientKey(client);
}
}