refactor(nestjs): Implement users module

This commit is contained in:
Ahmed Bouhuolia
2025-05-20 17:55:58 +02:00
parent ce058b9416
commit 99fe5a6b0d
48 changed files with 1823 additions and 207 deletions

View File

@@ -0,0 +1,27 @@
import { events } from '@/common/events/events';
import { SystemUser } from '@/modules/System/models/SystemUser';
import { Inject, Injectable } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter';
import { ITenantUserDeletedPayload } from '../Users.types';
@Injectable()
export class SyncTenantUserDeleteSubscriber {
constructor(
@Inject(SystemUser.name)
private readonly systemUserModel: typeof SystemUser,
) {}
/**
* Deletes the system user once tenant user be deleted.
* @param {ITenantUserDeletedPayload} payload -
*/
@OnEvent(events.tenantUser.onDeleted)
async syncSystemUserOnceUserDeleted({
tenantUser,
}: ITenantUserDeletedPayload) {
await this.systemUserModel
.query()
.where('id', tenantUser.systemUserId)
.delete();
}
}