forked from Yara724/api
YARA-1110
This commit is contained in:
@@ -74,42 +74,3 @@ 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;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import {
|
||||
CreateSuperAdminDto,
|
||||
CreateFieldExpertAdminDto,
|
||||
CreateRegistrarAdminDto,
|
||||
CreateFinancialExpertAdminDto,
|
||||
} from "./dto/super-admin.dto";
|
||||
import { ClientDto } from "src/client/dto/create-client.dto";
|
||||
import {
|
||||
@@ -130,18 +129,6 @@ 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")
|
||||
|
||||
@@ -19,12 +19,10 @@ 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 {
|
||||
@@ -35,7 +33,6 @@ 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). */
|
||||
@@ -102,29 +99,4 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user