forked from Yara724/api
Enforce claim beneficiary access and retire unused legacy APIs
This commit is contained in:
@@ -1,44 +1,15 @@
|
||||
import { extname } from "node:path";
|
||||
import {
|
||||
Controller,
|
||||
Post,
|
||||
Body,
|
||||
Param,
|
||||
UseGuards,
|
||||
Get,
|
||||
UseInterceptors,
|
||||
UploadedFile,
|
||||
} from "@nestjs/common";
|
||||
import {
|
||||
FileInterceptor,
|
||||
} from "@nestjs/platform-express";
|
||||
import { diskStorage } from "multer";
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
ApiBody,
|
||||
ApiParam,
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
ApiResponse,
|
||||
ApiConsumes,
|
||||
ApiExcludeController,
|
||||
} from "@nestjs/swagger";
|
||||
import { Body, Controller, Param, Post, UseGuards } from "@nestjs/common";
|
||||
import { ApiBearerAuth, ApiExcludeController } from "@nestjs/swagger";
|
||||
import { LocalActorAuthGuard } from "src/auth/guards/actor-local.guard";
|
||||
import { RolesGuard } from "src/auth/guards/role.guard";
|
||||
import { CurrentUser } from "src/decorators/user.decorator";
|
||||
|
||||
import { Roles } from "src/decorators/roles.decorator";
|
||||
import { CurrentUser } from "src/decorators/user.decorator";
|
||||
import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||
import { DEFAULT_MEDIA_MAX_BYTES } from "src/client/client.service";
|
||||
import { RequestManagementService } from "./request-management.service";
|
||||
import { CreateExpertInitiatedFileDto } from "./dto/expert-initiated.dto";
|
||||
import { ExpertCompleteThirdPartyFormDto } from "./dto/expert-complete-third-party-form.dto";
|
||||
import { ExpertCompleteCarBodyFormDto } from "./dto/expert-complete-car-body-form.dto";
|
||||
import { ExpertAccidentFieldsDto } from "./dto/expert-accident-fields.dto";
|
||||
import { ExpertCompleteClaimDataDto } from "./dto/expert-complete-claim-data.dto";
|
||||
import { ClaimRequestManagementService } from "src/claim-request-management/claim-request-management.service";
|
||||
import { RequestManagementService } from "./request-management.service";
|
||||
|
||||
@ApiExcludeController()
|
||||
// @ApiTags("expert-initiated-blame")
|
||||
@Controller("expert-initiated-blame")
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(LocalActorAuthGuard, RolesGuard)
|
||||
@@ -46,239 +17,9 @@ import { ClaimRequestManagementService } from "src/claim-request-management/clai
|
||||
export class ExpertInitiatedController {
|
||||
constructor(
|
||||
private readonly requestManagementService: RequestManagementService,
|
||||
private readonly claimRequestManagementService: ClaimRequestManagementService,
|
||||
) {}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Get("my-files")
|
||||
// @ApiOperation({
|
||||
// summary: "List my expert-initiated files",
|
||||
// description:
|
||||
// "Returns all blame files created by the current field expert (their panel).",
|
||||
// })
|
||||
// @ApiResponse({ status: 200, description: "List of expert-initiated files" })
|
||||
async getMyFiles(@CurrentUser() expert: any) {
|
||||
return await this.requestManagementService.getMyExpertInitiatedFiles(expert);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Post("complete-blame-data/:requestId")
|
||||
// @ApiParam({ name: "requestId", description: "ID of the expert-initiated file" })
|
||||
// @ApiBody({
|
||||
// description:
|
||||
// "Send ExpertCompleteThirdPartyFormDto for THIRD_PARTY files or ExpertCompleteCarBodyFormDto for CAR_BODY files (according to file type).",
|
||||
// })
|
||||
// @ApiResponse({ status: 200, description: "Blame form completed successfully" })
|
||||
async completeBlameData(
|
||||
@CurrentUser() expert: any,
|
||||
@Param("requestId") requestId: string,
|
||||
@Body() formData: any,
|
||||
) {
|
||||
return await this.requestManagementService.completeBlameData(
|
||||
expert,
|
||||
requestId,
|
||||
formData,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Post("complete-claim-data/:claimRequestId")
|
||||
// @ApiOperation({
|
||||
// summary: "Submit claim-needed data",
|
||||
// description:
|
||||
// "Field expert fills claim data for expert-initiated IN_PERSON files (car part damage, sheba, national code, other parts). " +
|
||||
// "Only the initiating expert can call this.",
|
||||
// })
|
||||
// @ApiParam({
|
||||
// name: "claimRequestId",
|
||||
// description: "ID of the claim file (created from the expert-initiated blame file)",
|
||||
// })
|
||||
// @ApiBody({ type: ExpertCompleteClaimDataDto })
|
||||
// @ApiResponse({ status: 200, description: "Claim data updated successfully" })
|
||||
async completeClaimData(
|
||||
@CurrentUser() expert: any,
|
||||
@Param("claimRequestId") claimRequestId: string,
|
||||
@Body() dto: ExpertCompleteClaimDataDto,
|
||||
) {
|
||||
return await this.claimRequestManagementService.expertCompleteClaimData(
|
||||
claimRequestId,
|
||||
expert,
|
||||
dto,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
// @Post("create")
|
||||
// @ApiOperation({
|
||||
// summary: "Create expert-initiated blame file",
|
||||
// description:
|
||||
// "Expert creates an initial incomplete blame file. Can be IN_PERSON (expert fills all info) or LINK (expert sends link to users).",
|
||||
// })
|
||||
// @ApiBody({ type: CreateExpertInitiatedFileDto })
|
||||
// @ApiResponse({
|
||||
// status: 201,
|
||||
// description: "File created successfully",
|
||||
// schema: {
|
||||
// type: "object",
|
||||
// properties: {
|
||||
// requestId: { type: "string" },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
// async createExpertInitiatedFile(
|
||||
// @CurrentUser() expert: any,
|
||||
// @Body() dto: CreateExpertInitiatedFileDto,
|
||||
// ) {
|
||||
// return await this.requestManagementService.createExpertInitiatedFile(
|
||||
// expert,
|
||||
// dto,
|
||||
// );
|
||||
// }
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Post("complete-form-third-party/:requestId")
|
||||
// @ApiParam({ name: "requestId" })
|
||||
// @ApiBody({ type: ExpertCompleteThirdPartyFormDto })
|
||||
// @ApiResponse({ status: 200, description: "Form completed successfully. File is now ready for user signatures." })
|
||||
async completeThirdPartyForm(
|
||||
@CurrentUser() expert: any,
|
||||
@Param("requestId") requestId: string,
|
||||
@Body() formData: ExpertCompleteThirdPartyFormDto,
|
||||
) {
|
||||
return await this.requestManagementService.expertCompleteThirdPartyForm(
|
||||
expert,
|
||||
requestId,
|
||||
formData,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Post("complete-form-car-body/:requestId")
|
||||
// @ApiOperation({
|
||||
// summary: "Expert completes all information for IN_PERSON CAR_BODY file",
|
||||
// description:
|
||||
// "Expert fills all information at once for IN_PERSON CAR_BODY files. " +
|
||||
// "Includes first party data and carBodyForm. " +
|
||||
// "Video and voice uploads are handled separately.",
|
||||
// })
|
||||
async completeCarBodyForm(
|
||||
@CurrentUser() expert: any,
|
||||
@Param("requestId") requestId: string,
|
||||
@Body() formData: ExpertCompleteCarBodyFormDto,
|
||||
) {
|
||||
return await this.requestManagementService.expertCompleteCarBodyForm(
|
||||
expert,
|
||||
requestId,
|
||||
formData,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Post("upload-video/:requestId")
|
||||
// @ApiParam({ name: "requestId" })
|
||||
// @ApiConsumes("multipart/form-data")
|
||||
// @ApiBody({
|
||||
// schema: {
|
||||
// type: "object",
|
||||
// properties: { file: { type: "string", format: "binary" } },
|
||||
// },
|
||||
// })
|
||||
@UseInterceptors(
|
||||
FileInterceptor("file", {
|
||||
limits: {
|
||||
fileSize: DEFAULT_MEDIA_MAX_BYTES,
|
||||
},
|
||||
storage: diskStorage({
|
||||
destination: "./files/video",
|
||||
filename: (req, file, callback) => {
|
||||
const unique = Date.now();
|
||||
const ex = extname(file.originalname);
|
||||
const filename = `expert-${file.originalname}-${unique}${ex}`;
|
||||
callback(null, filename);
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
// @ApiResponse({
|
||||
// status: 200,
|
||||
// description: "Video uploaded successfully",
|
||||
// })
|
||||
async uploadVideo(
|
||||
@CurrentUser() expert: any,
|
||||
@Param("requestId") requestId: string,
|
||||
@UploadedFile() file?: Express.Multer.File,
|
||||
) {
|
||||
return await this.requestManagementService.expertUploadVideo(
|
||||
expert,
|
||||
requestId,
|
||||
file,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Post("upload-voice/:requestId")
|
||||
// @ApiOperation({
|
||||
// summary: "Expert uploads voice for expert-initiated file",
|
||||
// description:
|
||||
// "Expert uploads a single voice file for the entire blame file. " +
|
||||
// "Only one voice is needed per file (not per party). " +
|
||||
// "Only works for expert-initiated files.",
|
||||
// })
|
||||
// @ApiParam({ name: "requestId" })
|
||||
// @ApiConsumes("multipart/form-data")
|
||||
// @ApiBody({
|
||||
// schema: {
|
||||
// type: "object",
|
||||
// properties: {
|
||||
// voice: {
|
||||
// type: "string",
|
||||
// format: "binary",
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
@UseInterceptors(
|
||||
FileInterceptor("voice", {
|
||||
limits: {
|
||||
fileSize: DEFAULT_MEDIA_MAX_BYTES,
|
||||
},
|
||||
storage: diskStorage({
|
||||
destination: "./files/voice",
|
||||
filename: (req, file, callback) => {
|
||||
const unique = Date.now();
|
||||
const ex = extname(file.originalname);
|
||||
const flname = file.originalname.split(".")[0];
|
||||
const filename = `expert-${flname}-${unique}${ex}`;
|
||||
callback(null, filename);
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
// @ApiResponse({ status: 200, description: "Voice uploaded successfully" })
|
||||
async uploadVoice(
|
||||
@CurrentUser() expert: any,
|
||||
@Param("requestId") requestId: string,
|
||||
@UploadedFile() voice?: Express.Multer.File,
|
||||
) {
|
||||
return await this.requestManagementService.expertUploadVoice(
|
||||
expert,
|
||||
requestId,
|
||||
voice,
|
||||
);
|
||||
}
|
||||
|
||||
// @ApiOperation({ deprecated: true })
|
||||
@Post("add-accident-fields/:requestId")
|
||||
// @ApiOperation({
|
||||
// summary: "Expert adds accident fields to expert-initiated file",
|
||||
// description:
|
||||
// "Expert adds accident way, reason, and type fields to an expert-initiated file. " +
|
||||
// "Can be used for both IN_PERSON and LINK-based files. " +
|
||||
// "If expertSubmitReply already exists, updates the fields. Otherwise, creates a new expertSubmitReply.",
|
||||
// })
|
||||
// @ApiParam({ name: "requestId" })
|
||||
// @ApiBody({ type: ExpertAccidentFieldsDto })
|
||||
// @ApiResponse({ status: 200, description: "Accident fields added successfully" })
|
||||
async addAccidentFields(
|
||||
@CurrentUser() expert: any,
|
||||
@Param("requestId") requestId: string,
|
||||
@@ -291,4 +32,3 @@ export class ExpertInitiatedController {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user