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,34 @@
import { Injectable } from "@nestjs/common";
import { InjectModel } from "@nestjs/mongoose";
import { FilterQuery, Model, Types } from "mongoose";
import { BranchModel, BranchDocument } from "../schema/branch.schema";
@Injectable()
export class BranchDbService {
constructor(
@InjectModel(BranchModel.name)
private readonly branchModel: Model<BranchModel>,
) {}
async create(branch: BranchModel): Promise<BranchModel> {
return await this.branchModel.create(branch);
}
async find(branch: FilterQuery<BranchModel>): Promise<BranchDocument> {
return await this.branchModel.findOne(branch);
}
async findOne(branch: FilterQuery<BranchModel>) {
return this.branchModel.findOne(branch);
}
async findAll(insuranceId: string): Promise<BranchModel[]> {
return await this.branchModel.find({
clientKey: new Types.ObjectId(insuranceId),
});
}
async findById(id: string): Promise<BranchModel | null> {
return this.branchModel.findById(id).lean();
}
}

View File

@@ -0,0 +1,28 @@
import { Injectable } from "@nestjs/common";
import { InjectModel } from "@nestjs/mongoose";
import { FilterQuery, Model } from "mongoose";
import { ClientModel, ClientDocument } from "../schema/client.schema";
@Injectable()
export class ClientDbService {
constructor(
@InjectModel(ClientModel.name)
private readonly clientModel: Model<ClientModel>,
) {}
async create(client: ClientModel): Promise<ClientModel> {
return await this.clientModel.create(client);
}
async find(client: FilterQuery<ClientModel>): Promise<ClientDocument> {
return await this.clientModel.findOne(client);
}
async findOne(client: FilterQuery<ClientModel>) {
return this.clientModel.findOne(client);
}
async findAll(): Promise<ClientModel[]> {
return await this.clientModel.find();
}
}

View File

@@ -0,0 +1,32 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Types } from "mongoose";
export type BranchDocument = BranchModel & Document;
@Schema({ collection: "branches", versionKey: false, timestamps: true })
export class BranchModel {
@Prop({ required: true, type: Types.ObjectId, ref: "ClientModel" })
clientKey: Types.ObjectId;
@Prop({ required: true })
name: string;
@Prop({ required: true })
code: string;
@Prop({ required: true })
city: string;
@Prop({ required: true })
state: string;
@Prop({ required: true })
address: string;
@Prop()
phoneNumber?: string;
}
export const BranchSchema = SchemaFactory.createForClass(BranchModel);
BranchSchema.index({ clientKey: 1, code: 1 }, { unique: true });

View File

@@ -0,0 +1,25 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
export type ClientDocument = ClientModel & Document;
@Schema({ collection: "clients", versionKey: false })
export class ClientModel {
@Prop({ required: true, unique: true, type: Object })
clientName: {
persian: string;
english: string;
};
@Prop({ required: false, unique: true, type: Object })
property: {
smsApiKey: string;
};
@Prop({ required: true, unique: false })
useExpertMode: "legal" | "genuine";
@Prop({ required: true, unique: false })
clientCode: number;
}
export const ClientDbSchema = SchemaFactory.createForClass(ClientModel);