YARA-1094, YARA-1095, YARA-1096

This commit is contained in:
SepehrYahyaee
2026-07-12 14:07:27 +03:30
parent c955deda5c
commit 72dec7a917
17 changed files with 1589 additions and 2 deletions

View File

@@ -74,3 +74,42 @@ export class CreateRegistrarAdminDto {
@IsNotEmpty()
clientId: string;
}
export class CreateFinancialExpertAdminDto {
@ApiProperty({ example: "financial@insurer.ir" })
@IsEmail()
email: string;
@ApiProperty({ example: "FinExpert@724" })
@IsString()
@IsNotEmpty()
password: string;
@ApiProperty({ example: "Ali" })
@IsString()
@IsNotEmpty()
firstName: string;
@ApiProperty({ example: "Mohammadi" })
@IsString()
@IsNotEmpty()
lastName: string;
@ApiProperty({ example: "09121234567" })
@IsString()
@IsNotEmpty()
mobile: string;
@ApiProperty({
example: "664a1b2c3d4e5f6789012345",
description: "Mongo ObjectId of the insurer client this financial expert belongs to.",
})
@IsString()
@IsNotEmpty()
clientId: string;
@ApiPropertyOptional({ example: "02112345678" })
@IsOptional()
@IsString()
phone?: string;
}

View File

@@ -19,6 +19,7 @@ import {
CreateSuperAdminDto,
CreateFieldExpertAdminDto,
CreateRegistrarAdminDto,
CreateFinancialExpertAdminDto,
} from "./dto/super-admin.dto";
import { ClientDto } from "src/client/dto/create-client.dto";
import {
@@ -129,6 +130,18 @@ export class SuperAdminController {
return this.superAdminService.createRegistrar(body);
}
@Post("create-financial-expert")
@ApiOperation({
summary: "Create a financial expert (V5 flow)",
description:
"FinancialExperts are the final approvers in the V5 blame flow before fanavaran submission. " +
"Scoped to the specified insurer client via clientId.",
})
@ApiBody({ type: CreateFinancialExpertAdminDto })
createFinancialExpert(@Body() body: CreateFinancialExpertAdminDto) {
return this.superAdminService.createFinancialExpert(body);
}
// ── System settings ──────────────────────────────────────────────────────
@Get("system-settings")

View File

@@ -19,10 +19,12 @@ import {
CreateSuperAdminDto,
CreateFieldExpertAdminDto,
CreateRegistrarAdminDto,
CreateFinancialExpertAdminDto,
} from "./dto/super-admin.dto";
import { RoleEnum } from "src/Types&Enums/role.enum";
import { FieldExpertDbService } from "src/users/entities/db-service/field-expert.db.service";
import { RegistrarDbService } from "src/users/entities/db-service/registrar.db.service";
import { FinancialExpertDbService } from "src/users/entities/db-service/financial-expert.db.service";
@Injectable()
export class SuperAdminService {
@@ -33,6 +35,7 @@ export class SuperAdminService {
private readonly actorAuthService: ActorAuthService,
private readonly fieldExpertDbService: FieldExpertDbService,
private readonly registrarDbService: RegistrarDbService,
private readonly financialExpertDbService: FinancialExpertDbService,
) {}
/** List all super-admin accounts (sans password). */
@@ -99,4 +102,29 @@ export class SuperAdminService {
async createRegistrar(body: CreateRegistrarAdminDto) {
return this.actorAuthService.createRegistrarMock(body);
}
async createFinancialExpert(body: CreateFinancialExpertAdminDto) {
const email = body.email.toLowerCase().trim();
const existing = await this.financialExpertDbService.findOne({ email });
if (existing) {
throw new ConflictException(
"A FinancialExpert with this email already exists.",
);
}
const hashedPassword = await this.hashService.hash(body.password);
const created = await this.financialExpertDbService.create({
email,
password: hashedPassword,
firstName: body.firstName,
lastName: body.lastName,
mobile: body.mobile,
phone: body.phone,
clientKey: new Types.ObjectId(body.clientId),
role: RoleEnum.FINANCIAL_EXPERT,
} as any);
const { password: _pw, ...rest } = (created as any).toObject
? (created as any).toObject()
: (created as any);
return rest;
}
}