diff --git a/src/modules/support-plans/entities/support-plan.entity.ts b/src/modules/support-plans/entities/support-plan.entity.ts index 5fd31c9..5a0ab51 100644 --- a/src/modules/support-plans/entities/support-plan.entity.ts +++ b/src/modules/support-plans/entities/support-plan.entity.ts @@ -2,6 +2,7 @@ import { Decimal } from "decimal.js"; import { Column, DeleteDateColumn, Entity, OneToMany } from "typeorm"; import { SupportPlanFeature } from "./support-plan-feature.entity"; +import { UserSupportPlan } from "./user-support-plan.entity"; import { BaseEntity } from "../../../common/entities/base.entity"; import { DecimalTransformer } from "../../../common/transformers/decimal.transformer"; @Entity() @@ -27,6 +28,9 @@ export class SupportPlan extends BaseEntity { @OneToMany(() => SupportPlanFeature, (feature) => feature.supportPlan, { cascade: true }) features: SupportPlanFeature[]; + @OneToMany(() => UserSupportPlan, (userSupportPlan) => userSupportPlan.supportPlan) + users: UserSupportPlan[]; + @DeleteDateColumn({ nullable: true }) deletedAt?: Date; } diff --git a/src/modules/support-plans/enums/support-plan-feature-key.enum.ts b/src/modules/support-plans/enums/support-plan-feature-key.enum.ts index 1c587d2..87a640e 100644 --- a/src/modules/support-plans/enums/support-plan-feature-key.enum.ts +++ b/src/modules/support-plans/enums/support-plan-feature-key.enum.ts @@ -1,11 +1,13 @@ export enum SupportPlanFeatureKey { LEARNING_DOCS = "learning_docs", // راهنما و مستندات آموزشی TICKET_SUPPORT = "ticket_support", // ارسال تیکت + TICKET_LIMIT = "ticket_limit", // ظرفیت ارسال تیکت RESPONSE_TIME = "response_time", // زمان پاسخگویی به تیکت PHONE_SUPPORT = "phone_support", // پاسخگویی تلفنی - BACKUP_VERSION = "backup_version", // نسخه بکاپ + TECHNICAL_ISSUE_RESOLUTION = "technical_issue_resolution", // رفع ایراد فنی TECHNICAL_EXPERT_ACCESS = "technical_expert_access", // دسترسی به متخصصین فنی + BACKUP_VERSION = "backup_version", // نسخه بکاپ + SERVICE_FUNCTIONALITY_TEST = "service_functionality_test", // تست عملکرد سرویس ON_SITE_SUPPORT = "on_site_support", // پشتیبانی در محل ON_SITE_TRAINING = "on_site_training", // آموزش در محل - TICKET_LIMIT = "ticket_limit", // ظرفیت ارسال تیکت } diff --git a/src/modules/support-plans/repositories/support-plan.repository.ts b/src/modules/support-plans/repositories/support-plan.repository.ts index 6070145..deb7362 100644 --- a/src/modules/support-plans/repositories/support-plan.repository.ts +++ b/src/modules/support-plans/repositories/support-plan.repository.ts @@ -16,6 +16,7 @@ export class SupportPlanRepository extends Repository { async getSupportPlansListAdmin(queryDto: GetSupportPlanListQueryDto) { const { limit, skip } = PaginationUtils(queryDto); const query = this.createQueryBuilder("supportPlan").where("supportPlan.deletedAt IS NULL"); + query.loadRelationCountAndMap("supportPlan.userCount", "supportPlan.users"); if (queryDto.q) { query.andWhere("supportPlan.name ILIKE :q OR supportPlan.description ILIKE :q", { q: `%${queryDto.q}%` });