refactor: dynamic list to nestjs

This commit is contained in:
Ahmed Bouhuolia
2025-01-12 18:22:48 +02:00
parent ddaea20d16
commit 270b421a6c
117 changed files with 4232 additions and 1493 deletions

View File

@@ -7,6 +7,7 @@ import { ActivateTaxRateService } from './commands/ActivateTaxRate.service';
import { InactivateTaxRateService } from './commands/InactivateTaxRate';
import { Injectable } from '@nestjs/common';
import { ICreateTaxRateDTO, IEditTaxRateDTO } from './TaxRates.types';
import { GetTaxRatesService } from './queries/GetTaxRates.service';
@Injectable()
export class TaxRatesApplication {
@@ -17,7 +18,7 @@ export class TaxRatesApplication {
private readonly getTaxRateService: GetTaxRateService,
private readonly activateTaxRateService: ActivateTaxRateService,
private readonly inactivateTaxRateService: InactivateTaxRateService,
// private readonly getTaxRatesService: GetTaxRatesService,
private readonly getTaxRatesService: GetTaxRatesService,
) {}
/**
@@ -56,17 +57,16 @@ export class TaxRatesApplication {
* @param {number} taxRateId
* @returns {Promise<ITaxRate>}
*/
public getTaxRate(tenantId: number, taxRateId: number) {
public getTaxRate(taxRateId: number) {
return this.getTaxRateService.getTaxRate(taxRateId);
}
/**
* Retrieves the tax rates list.
* @param {number} tenantId
* @returns {Promise<ITaxRate[]>}
*/
public getTaxRates(tenantId: number) {
// return this.getTaxRatesService.getTaxRates(tenantId);
public getTaxRates() {
return this.getTaxRatesService.getTaxRates();
}
/**

View File

@@ -35,16 +35,13 @@ export class TaxRatesController {
}
@Get(':id')
public getTaxRate(
@Param('tenantId') tenantId: number,
@Param('id') taxRateId: number,
) {
return this.taxRatesApplication.getTaxRate(tenantId, taxRateId);
public getTaxRate(@Param('id') taxRateId: number) {
return this.taxRatesApplication.getTaxRate(taxRateId);
}
@Get()
public getTaxRates(@Param('tenantId') tenantId: number) {
return this.taxRatesApplication.getTaxRates(tenantId);
public getTaxRates() {
return this.taxRatesApplication.getTaxRates();
}
@Put(':id/activate')

View File

@@ -1,32 +1,24 @@
// import { Inject, Service } from 'typedi';
// import HasTenancyService from '../Tenancy/TenancyService';
// import { TransformerInjectable } from '@/lib/Transformer/TransformerInjectable';
// import { TaxRateTransformer } from './TaxRate.transformer';
import { Inject, Injectable } from '@nestjs/common';
import { TaxRateTransformer } from './TaxRate.transformer';
import { TransformerInjectable } from '@/modules/Transformer/TransformerInjectable.service';
import { TaxRateModel } from '../models/TaxRate.model';
// @Service()
// export class GetTaxRatesService {
// @Inject()
// private tenancy: HasTenancyService;
@Injectable()
export class GetTaxRatesService {
constructor(
private transformer: TransformerInjectable,
@Inject(TaxRateModel.name) private taxRateModel: typeof TaxRateModel,
) {}
// @Inject()
// private transformer: TransformerInjectable;
/**
* Retrieves the tax rates list.
* @returns {Promise<ITaxRate[]>}
*/
public async getTaxRates() {
// Retrieves the tax rates.
const taxRates = await this.taxRateModel.query().orderBy('name', 'ASC');
// /**
// * Retrieves the tax rates list.
// * @param {number} tenantId
// * @returns {Promise<ITaxRate[]>}
// */
// public async getTaxRates(tenantId: number) {
// const { TaxRate } = this.tenancy.models(tenantId);
// // Retrieves the tax rates.
// const taxRates = await TaxRate.query().orderBy('name', 'ASC');
// // Transforms the tax rates.
// return this.transformer.transform(
// tenantId,
// taxRates,
// new TaxRateTransformer()
// );
// }
// }
// Transforms the tax rates.
return this.transformer.transform(taxRates, new TaxRateTransformer());
}
}