refactor: tenant proxy providers

This commit is contained in:
Ahmed Bouhuolia
2025-02-15 23:52:12 +02:00
parent 36851d3209
commit 5c0bb52b59
302 changed files with 2396 additions and 1677 deletions

View File

@@ -1,12 +1,13 @@
import { Inject } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { Branch } from '../models/Branch.model';
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
@Injectable()
export class GetBranchService {
constructor(
@Inject(Branch.name)
private readonly branch: typeof Branch,
private readonly branch: TenantModelProxy<typeof Branch>,
) {}
/**
@@ -15,7 +16,7 @@ export class GetBranchService {
* @returns {Promise<IBranch>}
*/
public getBranch = async (branchId: number): Promise<Branch> => {
const branch = await this.branch
const branch = await this.branch()
.query()
.findById(branchId)
.throwIfNotFound();

View File

@@ -1,11 +1,12 @@
import { Inject, Injectable } from '@nestjs/common';
import { Branch } from '../models/Branch.model';
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
@Injectable()
export class GetBranchesService {
constructor(
@Inject(Branch.name)
private readonly branch: typeof Branch,
private readonly branch: TenantModelProxy<typeof Branch>,
) {}
/**
@@ -13,7 +14,7 @@ export class GetBranchesService {
* @returns
*/
public getBranches = async () => {
const branches = await this.branch.query().orderBy('name', 'DESC');
const branches = await this.branch().query().orderBy('name', 'DESC');
return branches;
};