update: add company services and products

This commit is contained in:
Mahyargdz
2025-05-11 16:45:26 +03:30
parent 9a9f640622
commit 77c0f59514
18 changed files with 588 additions and 33 deletions
@@ -1,5 +1,25 @@
import { EntityRepository } from "@mikro-orm/core";
import { PaginationUtils } from "../../utils/providers/pagination.utils";
import { CompanyListQueryDto } from "../DTO/company-list-query.dto";
import { Company } from "../entities/company.entity";
export class CompanyRepository extends EntityRepository<Company> {}
export class CompanyRepository extends EntityRepository<Company> {
//
async getCompaniesListForAdmin(queryDto: CompanyListQueryDto) {
const { limit, skip } = PaginationUtils(queryDto);
return await this.findAndCount(
{
deletedAt: null,
...(queryDto.status && { status: queryDto.status }),
...(queryDto.q && { name: { $ilike: `%${queryDto.q}%` } }),
...(queryDto.industryId && { industry: { id: queryDto.industryId } }),
...(queryDto.isActive !== undefined && { isActive: queryDto.isActive === 1 }),
...(queryDto.registrationDate && { createdAt: { $gte: queryDto.registrationDate, $lte: queryDto.registrationDate } }),
...(queryDto.name && { name: { $ilike: `%${queryDto.name}%` } }),
},
{ offset: skip, limit, orderBy: { createdAt: "DESC" } },
);
}
}