mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
refactor: tenant proxy providers
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user