feat: add detail formula api getter
continuous-integration/drone/tag Build is passing
Details
continuous-integration/drone/tag Build is passing
Details
parent
45c4bde838
commit
9d98003a2d
|
@ -0,0 +1,56 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
Param,
|
||||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
import { FormulaType } from 'src/modules/transaction/sales-price-formula/constants';
|
||||
import { SalesPriceFormulaEntity } from 'src/modules/transaction/sales-price-formula/domain/entities/sales-price-formula.entity';
|
||||
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
||||
import { SelectQueryBuilder } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class IndexProfitShareFormulaManager extends BaseIndexManager<SalesPriceFormulaEntity> {
|
||||
setQueryFilter(
|
||||
queryBuilder: SelectQueryBuilder<SalesPriceFormulaEntity>,
|
||||
): SelectQueryBuilder<SalesPriceFormulaEntity> {
|
||||
return queryBuilder;
|
||||
}
|
||||
|
||||
get specificFilter(): Param[] {
|
||||
return [
|
||||
{
|
||||
cols: `${this.tableName}.type::text`,
|
||||
data: [FormulaType.PROFIT_SHARE],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
async prepareData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get relations(): RelationParam {
|
||||
return {
|
||||
// relation only join (for query purpose)
|
||||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: [],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
};
|
||||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [];
|
||||
}
|
||||
}
|
|
@ -3,14 +3,24 @@ import { DetailProfitShareFormulaManager } from './managers/detail-profit-share-
|
|||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { SalesPriceFormulaReadService } from 'src/modules/transaction/sales-price-formula/data/services/sales-price-formula-read.service';
|
||||
import { SalesPriceFormulaEntity } from 'src/modules/transaction/sales-price-formula/domain/entities/sales-price-formula.entity';
|
||||
import { IndexProfitShareFormulaManager } from './managers/index-profit-share-formula.manager';
|
||||
|
||||
@Injectable()
|
||||
export class ProfitShareFormulaReadOrchestrator {
|
||||
constructor(
|
||||
private detailManager: DetailProfitShareFormulaManager,
|
||||
private indexManager: IndexProfitShareFormulaManager,
|
||||
private serviceData: SalesPriceFormulaReadService,
|
||||
) {}
|
||||
|
||||
async index(): Promise<SalesPriceFormulaEntity[]> {
|
||||
this.indexManager.setFilterParam({});
|
||||
this.indexManager.setService(this.serviceData, TABLE_NAME.PRICE_FORMULA);
|
||||
await this.indexManager.execute();
|
||||
const { data } = this.indexManager.getResult();
|
||||
return data;
|
||||
}
|
||||
|
||||
async detail(): Promise<SalesPriceFormulaEntity> {
|
||||
this.detailManager.setData('');
|
||||
this.detailManager.setService(this.serviceData, TABLE_NAME.PRICE_FORMULA);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { ProfitShareFormulaReadOrchestrator } from '../domain/usecases/profit-share-formula-read.orchestrator';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { Public } from 'src/core/guards';
|
||||
|
@ -15,4 +15,9 @@ export class ProfitShareFormulaReadController {
|
|||
async detail(): Promise<SalesPriceFormulaEntity> {
|
||||
return await this.orchestrator.detail();
|
||||
}
|
||||
|
||||
@Get('detail')
|
||||
async breakdown(): Promise<SalesPriceFormulaEntity[]> {
|
||||
return await this.orchestrator.index();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import { DetailProfitShareFormulaManager } from './domain/usecases/managers/deta
|
|||
import { SalesPriceFormulaModel } from '../sales-price-formula/data/models/sales-price-formula.model';
|
||||
import { TaxDataService } from '../tax/data/services/tax-data.service';
|
||||
import { TaxModel } from '../tax/data/models/tax.model';
|
||||
import { IndexProfitShareFormulaManager } from './domain/usecases/managers/index-profit-share-formula.manager';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -29,6 +30,7 @@ import { TaxModel } from '../tax/data/models/tax.model';
|
|||
providers: [
|
||||
DetailProfitShareFormulaManager,
|
||||
UpdateProfitShareFormulaManager,
|
||||
IndexProfitShareFormulaManager,
|
||||
|
||||
ProfitShareFormulaDataOrchestrator,
|
||||
ProfitShareFormulaReadOrchestrator,
|
||||
|
|
Loading…
Reference in New Issue