1
0
forked from Yara724/api

Initial commit after migration to gitea

This commit is contained in:
2026-01-18 11:27:43 +03:30
parent a21039410c
commit ea4b8eb543
196 changed files with 45567 additions and 9 deletions

View File

@@ -0,0 +1,197 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Types } from "mongoose";
import {
ExpertizedAtEnum,
PreviousWorkEnum,
SkillEnum,
} from "src/Types&Enums/damage-expert.enum";
import { RoleEnum } from "src/Types&Enums/role.enum";
import { UserType } from "src/Types&Enums/userType.enum";
@Schema({ _id: false })
export class RequestStats {
@Prop({ default: 0 })
totalHandled: number;
@Prop({ default: 0 })
totalChecked: number;
}
const RequestStatsSchema = SchemaFactory.createForClass(RequestStats);
@Schema({ _id: false })
export class PersonalInfo {
@Prop({ type: "string" })
fullName: string;
@Prop({ type: "string" })
nationalCode: string;
@Prop({ type: "string" })
dob: string;
@Prop({ type: "string" })
mobile: string;
}
const PersonalInfoSchema = SchemaFactory.createForClass(PersonalInfo);
@Schema({ _id: false })
export class PersonalDocs {
@Prop({ type: "string" })
nationalCard?: string;
@Prop({ type: "string" })
selfie?: string;
@Prop({ type: "string" })
activityCert?: string;
}
const PersonalDocsSchema = SchemaFactory.createForClass(PersonalDocs);
@Schema({ _id: false })
export class WorkExperience {
@Prop({ type: Number })
state: number;
@Prop({ type: Number })
city: number;
@Prop({
type: [{ type: String, enum: ExpertizedAtEnum }],
default: [],
})
expertizedAt: ExpertizedAtEnum[];
}
const WorkExperienceSchema = SchemaFactory.createForClass(WorkExperience);
@Schema({ _id: false })
export class WorkRecords {
@Prop({ type: Number })
workingYears: number;
@Prop({ type: Number })
casesCount: number;
@Prop({ type: String, enum: PreviousWorkEnum })
previousWork: PreviousWorkEnum;
}
const WorkRecordsSchema = SchemaFactory.createForClass(WorkRecords);
@Schema({ _id: false })
export class FinancialInfo {
@Prop({ type: "string" })
IBAN: string;
@Prop({ type: "string" })
cardNum: string;
@Prop({ type: "string" })
accountNum: string;
}
const FinancialInfoSchema = SchemaFactory.createForClass(FinancialInfo);
@Schema({ collection: "damage-expert", versionKey: false, timestamps: true })
export class DamageExpertModel {
@Prop({ required: true })
userType: UserType;
@Prop({ required: true })
firstName: string;
@Prop({ required: true })
role: RoleEnum;
@Prop({ required: true })
lastName: string;
@Prop({ unique: true })
nationalCode: string;
@Prop({ type: "string", unique: true })
email: string;
@Prop({ type: "string" })
username: string;
@Prop({ required: true })
password: string;
@Prop({ required: true })
mobile: string;
@Prop({ required: false })
insuActivityCo?: string | null;
@Prop({ type: Types.ObjectId })
clientKey?: Types.ObjectId;
@Prop({ type: PersonalInfoSchema })
personalInfo?: PersonalInfo;
@Prop({ type: PersonalDocsSchema })
personalDocs?: PersonalDocs;
@Prop({ type: WorkExperienceSchema })
workExperience?: WorkExperience;
@Prop({ type: WorkRecordsSchema })
workRecords?: WorkRecords;
@Prop({
type: [{ type: String, enum: SkillEnum }],
default: [],
})
skills?: SkillEnum[];
@Prop({ type: FinancialInfoSchema })
financialInfo?: FinancialInfo;
@Prop({ type: "string" })
otp: string;
@Prop({ type: "string" })
address: string;
@Prop({ type: "string" })
state: string;
@Prop({ type: "string" })
city: string;
@Prop({ type: RequestStatsSchema, default: () => ({}) })
requestStats: RequestStats;
@Prop({
type: [{ type: String }],
default: [],
validate: {
validator: (arr: any[]) => arr.every((val) => typeof val === "string"),
message: "All countedRequests must be strings",
},
})
countedRequests?: string[];
createdAt: Date;
}
export const DamageExpertDbSchema =
SchemaFactory.createForClass(DamageExpertModel);
DamageExpertDbSchema.pre("save", function (next) {
if (!this.username) {
this.username = this.email;
}
next();
});
DamageExpertDbSchema.pre("save", function (next) {
if (!this.requestStats) {
this.requestStats = { totalChecked: 0, totalHandled: 0 };
}
next();
});

View File

@@ -0,0 +1,105 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Degrees } from "src/Types&Enums/degrees.enum";
import { RoleEnum } from "src/Types&Enums/role.enum";
import { UserType } from "src/Types&Enums/userType.enum";
@Schema({ _id: false })
export class RequestStats {
@Prop({ default: 0 })
totalHandled: number;
@Prop({ default: 0 })
totalChecked: number;
}
const RequestStatsSchema = SchemaFactory.createForClass(RequestStats);
@Schema({ collection: "expert", versionKey: false, timestamps: true })
export class ExpertModel {
@Prop({})
firstName: string;
@Prop({})
role: RoleEnum;
@Prop({})
userType: UserType;
@Prop({})
lastName: string;
@Prop({ unique: true })
nationalCode: string;
@Prop({ type: "string", unique: true })
email: string;
@Prop({})
password: string;
@Prop({})
sheba: string;
@Prop({})
phone: string;
@Prop({})
mobile: string;
@Prop({})
city: string;
@Prop({})
state: string;
@Prop({})
address: string;
@Prop({ type: String })
expDegree: Degrees;
@Prop({})
insuActivityTime?: number;
@Prop({})
insuActivityCo?: string;
@Prop({})
policeActivityTime?: number;
@Prop({})
policeActivityKind?: string;
@Prop({})
policeServicePlace?: string;
@Prop({})
clientKey?: string;
@Prop({ type: "string" })
otp: string;
@Prop({ type: RequestStatsSchema, default: () => ({}) })
requestStats: RequestStats;
@Prop({
type: [{ type: String }],
default: [],
validate: {
validator: (arr: any[]) => arr.every((val) => typeof val === "string"),
message: "All countedRequests must be strings",
},
})
countedRequests?: string[];
createdAt: Date;
}
export const ExpertDbSchema = SchemaFactory.createForClass(ExpertModel);
ExpertDbSchema.pre("save", function (next) {
if (!this.requestStats) {
this.requestStats = { totalChecked: 0, totalHandled: 0 };
}
next();
});

View File

@@ -0,0 +1,32 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Types } from "mongoose";
import { RoleEnum } from "src/Types&Enums/role.enum";
@Schema({
collection: "insurer-expert",
versionKey: false,
timestamps: true,
})
export class InsurerExpertModel {
@Prop()
firstName: string;
@Prop()
lastName: string;
@Prop({ unique: true, required: true })
email: string;
@Prop()
password: string;
@Prop()
role: RoleEnum;
@Prop()
clientKey: Types.ObjectId;
createdAt: Date;
}
export const InsurerExpertDbSchema =
SchemaFactory.createForClass(InsurerExpertModel);

View File

@@ -0,0 +1,57 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Types } from "mongoose";
import { Plates } from "src/Types&Enums/plate.interface";
export type UserDocument = UserModel & Document;
@Schema({ collection: "user", versionKey: false })
export class UserModel {
@Prop({ type: String, unique: true })
username: string;
@Prop({})
otp: string;
@Prop({ default: 0 })
otpExpire: number | null;
@Prop({ type: Object })
tokens: {
token: string;
rfToken: string;
};
@Prop()
fullName: string;
@Prop({ type: String })
mobile: string;
@Prop({ unique: false })
nationalCode: string;
@Prop({ type: Array })
plates?: Plates[];
@Prop()
lastLogin: Date;
@Prop()
clientKey: Types.ObjectId;
@Prop()
birthDay: string;
@Prop()
gender?: "male" | "female";
@Prop()
city: string;
@Prop()
address: string;
@Prop()
state: string;
}
export const UserDbSchema = SchemaFactory.createForClass(UserModel);