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,56 @@
import { BadGatewayException, GoneException, Injectable } from "@nestjs/common";
import { Types } from "mongoose";
import {
ClientDto,
ClientDtoRs,
ClientLists,
} from "src/client/dto/create-client.dto";
import { ClientDbService } from "./entities/db-service/client.db.service";
@Injectable()
export class ClientService {
constructor(private readonly clientDbService: ClientDbService) {}
async addClient(client: ClientDto): Promise<ClientDtoRs> {
try {
const newClient = await this.clientDbService.create({
clientCode: client.clientCode,
clientName: {
persian: client.clientName.persian,
english: client.clientName.english || null,
},
property: {
smsApiKey: client.property.smsApiKey || null,
},
useExpertMode: client.useExpertMode || null,
});
if (newClient) return new ClientDtoRs(newClient);
else throw new GoneException("database not connected");
} catch (er) {
throw new BadGatewayException(er.errors);
}
}
findOne(filter) {
return this.clientDbService.findOne(filter);
}
async findClientWithPersianName(filter: string) {
return await this.clientDbService.find({ "clientName.persian": filter });
}
async findClientWithCompanyCode(companyCode: number) {
return await this.clientDbService.find({ clientCode: companyCode });
}
async getClients(): Promise<ClientDtoRs[]> {
const clients = await this.clientDbService.findAll();
const show = clients.map((c) => new ClientDtoRs(c));
return show;
}
async getClientList(): Promise<ClientLists[]> {
const client = await this.clientDbService.findAll();
const list = client.map((element) => new ClientLists(element));
return list;
}
}