feat: add support plan but not tested
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InjectRepository } from "@nestjs/typeorm";
|
||||
import { IsNull, Repository } from "typeorm";
|
||||
|
||||
import { PaginationUtils } from "../../utils/providers/pagination.utils";
|
||||
import { GetSupportPlanListQueryDto } from "../DTO/get-support-plan-list-query.dto";
|
||||
import { SupportPlan } from "../entities/support-plan.entity";
|
||||
|
||||
@Injectable()
|
||||
export class SupportPlanRepository extends Repository<SupportPlan> {
|
||||
constructor(@InjectRepository(SupportPlan) supportPlanRepo: Repository<SupportPlan>) {
|
||||
super(supportPlanRepo.target, supportPlanRepo.manager, supportPlanRepo.queryRunner);
|
||||
}
|
||||
|
||||
//***************************************** */
|
||||
async getSupportPlansListAdmin(queryDto: GetSupportPlanListQueryDto) {
|
||||
const { limit, skip } = PaginationUtils(queryDto);
|
||||
const query = this.createQueryBuilder("supportPlan").where("supportPlan.deletedAt IS NULL");
|
||||
|
||||
if (queryDto.q) {
|
||||
query.andWhere("supportPlan.name ILIKE :q OR supportPlan.description ILIKE :q", { q: `%${queryDto.q}%` });
|
||||
}
|
||||
|
||||
if (queryDto.isActive !== undefined) {
|
||||
query.andWhere("supportPlan.isActive = :isActive", { isActive: queryDto.isActive === 1 });
|
||||
}
|
||||
|
||||
query.skip(skip).take(limit).orderBy("supportPlan.createdAt", "DESC");
|
||||
return query.getManyAndCount();
|
||||
}
|
||||
//***************************************** */
|
||||
async getSupportPlanById(id: string) {
|
||||
return this.findOne({ where: { id, deletedAt: IsNull() }, relations: { features: true } });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user