update: add company services and products
This commit is contained in:
@@ -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" } },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user