import { Injectable } from '@nestjs/common'; import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager'; import { EventTopics, validateRelations, } from 'src/core/strings/constants/interface.constants'; import { TenantChangeStatusEvent } from '../../entities/event/tenant-change-status.event'; import { UserModel } from 'src/modules/user-related/user/data/models/user.model'; import { UserEntity } from 'src/modules/user-related/user/domain/entities/user.entity'; import { SelectQueryBuilder } from 'typeorm'; import { STATUS } from 'src/core/strings/constants/base.constants'; @Injectable() export class InactiveTenantManager extends BaseUpdateStatusManager { get validateRelations(): validateRelations[] { return [ { relation: 'items', query: (qb: SelectQueryBuilder) => { return qb.andWhere('total_items.status In (:...statuses)', { statuses: [STATUS.ACTIVE], }); }, message: 'Failed! There is active item', }, ]; } getResult(): string { return `Success inactive data ${this.result.name}`; } async validateProcess(): Promise { return; } async beforeProcess(): Promise { return; } async afterProcess(): Promise { return; } get entityTarget(): any { return UserModel; } get eventTopics(): EventTopics[] { return [ { topic: TenantChangeStatusEvent, data: this.data, }, ]; } }