deat(SPG-380) REST API Read Metode Pembayaran
continuous-integration/drone/tag Build is failing
Details
continuous-integration/drone/tag Build is failing
Details
parent
0ce8c8402e
commit
30b8aa2083
|
@ -0,0 +1,9 @@
|
|||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
export interface FilterPaymentMethodEntity extends BaseFilterEntity {
|
||||
types: string[];
|
||||
issuers: string[];
|
||||
account_numbers: string[];
|
||||
account_names: string[];
|
||||
notes: string[];
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDetailManager } from 'src/core/modules/domain/usecase/managers/base-detail.manager';
|
||||
import { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import { RelationParam } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class DetailPaymentMethodManager extends BaseDetailManager<PaymentMethodEntity> {
|
||||
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 [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.type`,
|
||||
`${this.tableName}.issuer_name`,
|
||||
`${this.tableName}.account_number`,
|
||||
`${this.tableName}.account_name`,
|
||||
`${this.tableName}.qr_image`,
|
||||
`${this.tableName}.note`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.updated_at`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.editor_name`,
|
||||
];
|
||||
}
|
||||
|
||||
get setFindProperties(): any {
|
||||
return {
|
||||
id: this.dataId,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
||||
import { PaymentMethodEntity } from '../../entities/payment-method.entity';
|
||||
import { SelectQueryBuilder } from 'typeorm';
|
||||
import {
|
||||
Param,
|
||||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class IndexPaymentMethodManager extends BaseIndexManager<PaymentMethodEntity> {
|
||||
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 [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.type`,
|
||||
`${this.tableName}.issuer_name`,
|
||||
`${this.tableName}.account_number`,
|
||||
`${this.tableName}.account_name`,
|
||||
`${this.tableName}.qr_image`,
|
||||
`${this.tableName}.note`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.updated_at`,
|
||||
`${this.tableName}.creator_name`,
|
||||
`${this.tableName}.editor_name`,
|
||||
];
|
||||
}
|
||||
|
||||
get specificFilter(): Param[] {
|
||||
return [
|
||||
{
|
||||
cols: `${this.tableName}.issuer_name`,
|
||||
data: this.filterParam.names,
|
||||
},
|
||||
{
|
||||
cols: `${this.tableName}.issuer_name`,
|
||||
data: this.filterParam.issuers,
|
||||
},
|
||||
{
|
||||
cols: `${this.tableName}.type`,
|
||||
data: this.filterParam.types,
|
||||
},
|
||||
{
|
||||
cols: `${this.tableName}.account_number`,
|
||||
data: this.filterParam.account_numbers,
|
||||
},
|
||||
{
|
||||
cols: `${this.tableName}.account_name`,
|
||||
data: this.filterParam.account_names,
|
||||
},
|
||||
{
|
||||
cols: `${this.tableName}.note`,
|
||||
data: this.filterParam.notes,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
setQueryFilter(
|
||||
queryBuilder: SelectQueryBuilder<PaymentMethodEntity>,
|
||||
): SelectQueryBuilder<PaymentMethodEntity> {
|
||||
return queryBuilder;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { IndexPaymentMethodManager } from './managers/index-payment-method.manager';
|
||||
import { PaymentMethodReadService } from '../../data/services/payment-method-read.service';
|
||||
import { PaymentMethodEntity } from '../entities/payment-method.entity';
|
||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
|
||||
import { DetailPaymentMethodManager } from './managers/detail-payment-method.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class PaymentMethodReadOrchestrator extends BaseReadOrchestrator<PaymentMethodEntity> {
|
||||
constructor(
|
||||
private indexManager: IndexPaymentMethodManager,
|
||||
private detailManager: DetailPaymentMethodManager,
|
||||
private serviceData: PaymentMethodReadService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async index(params): Promise<PaginationResponse<PaymentMethodEntity>> {
|
||||
this.indexManager.setFilterParam(params);
|
||||
this.indexManager.setService(this.serviceData, TABLE_NAME.PAYMENT_METHOD);
|
||||
await this.indexManager.execute();
|
||||
return this.indexManager.getResult();
|
||||
}
|
||||
|
||||
async detail(dataId: string): Promise<PaymentMethodEntity> {
|
||||
this.detailManager.setData(dataId);
|
||||
this.detailManager.setService(this.serviceData, TABLE_NAME.PAYMENT_METHOD);
|
||||
await this.detailManager.execute();
|
||||
return this.detailManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.dto';
|
||||
import { FilterPaymentMethodEntity } from '../../domain/entities/filter-payment-method.entity';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
|
||||
export class FilterPaymentMethodDto
|
||||
extends BaseFilterDto
|
||||
implements FilterPaymentMethodEntity
|
||||
{
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
types: string[];
|
||||
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
issuers: string[];
|
||||
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
account_numbers: string[];
|
||||
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
account_names: string[];
|
||||
|
||||
@ApiProperty({ type: ['string'], required: false })
|
||||
@Transform((body) => {
|
||||
return Array.isArray(body.value) ? body.value : [body.value];
|
||||
})
|
||||
notes: string[];
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
import { Controller, Get, Param, Query } from '@nestjs/common';
|
||||
import { FilterPaymentMethodDto } from './dto/filter-payment-method.dto';
|
||||
import { Pagination } from 'src/core/response';
|
||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||
import { PaymentMethodEntity } from '../domain/entities/payment-method.entity';
|
||||
import { PaymentMethodReadOrchestrator } from '../domain/usecases/payment-method-read.orchestrator';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||
import { Public } from 'src/core/guards';
|
||||
|
||||
@ApiTags(`${MODULE_NAME.PAYMENT_METHOD.split('-').join(' ')} - read`)
|
||||
@Controller(MODULE_NAME.PAYMENT_METHOD)
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class PaymentMethodReadController {
|
||||
constructor(private orchestrator: PaymentMethodReadOrchestrator) {}
|
||||
|
||||
@Get()
|
||||
@Pagination()
|
||||
async index(
|
||||
@Query() params: FilterPaymentMethodDto,
|
||||
): Promise<PaginationResponse<PaymentMethodEntity>> {
|
||||
return await this.orchestrator.index(params);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async detail(@Param('id') id: string): Promise<PaymentMethodEntity> {
|
||||
return await this.orchestrator.detail(id);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue