forked from Yara724/api
62 lines
1.4 KiB
TypeScript
62 lines
1.4 KiB
TypeScript
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
|
import { Types } from "mongoose";
|
|
import { RoleEnum } from "src/Types&Enums/role.enum";
|
|
|
|
/**
|
|
* Call-center agent actor. Works under an insurance company (clientKey) and
|
|
* can start V6 LINK blame files on behalf of callers.
|
|
*/
|
|
@Schema({
|
|
collection: "call-center-agents",
|
|
versionKey: false,
|
|
timestamps: true,
|
|
})
|
|
export class CallCenterAgentModel {
|
|
_id?: Types.ObjectId;
|
|
|
|
@Prop({ required: true })
|
|
firstName: string;
|
|
|
|
@Prop({ required: true })
|
|
lastName: string;
|
|
|
|
@Prop({ type: String, unique: true, sparse: true, required: false })
|
|
email?: string;
|
|
|
|
@Prop({ type: String })
|
|
username?: string;
|
|
|
|
@Prop({ type: String, index: true, sparse: true })
|
|
nationalCode?: string;
|
|
|
|
@Prop({ type: Types.ObjectId, index: true })
|
|
clientKey?: Types.ObjectId;
|
|
|
|
@Prop({ required: true })
|
|
password: string;
|
|
|
|
@Prop({ required: false })
|
|
mobile?: string;
|
|
|
|
@Prop({ required: false })
|
|
phone?: string;
|
|
|
|
@Prop({ default: RoleEnum.CALL_CENTER })
|
|
role: RoleEnum;
|
|
|
|
@Prop({ type: "string", default: "" })
|
|
otp: string;
|
|
|
|
createdAt: Date;
|
|
}
|
|
|
|
export const CallCenterAgentDbSchema =
|
|
SchemaFactory.createForClass(CallCenterAgentModel);
|
|
|
|
CallCenterAgentDbSchema.pre("save", function (next) {
|
|
if (!this.username) {
|
|
this.username = (this as any).email || (this as any).nationalCode;
|
|
}
|
|
next();
|
|
});
|