45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { Controller, Get, Param, Query } from '@nestjs/common';
|
|
import { FilterTransactionDto } from './dto/filter-transaction.dto';
|
|
import { Pagination } from 'src/core/response';
|
|
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
|
import { TransactionEntity } from '../domain/entities/transaction.entity';
|
|
import { TransactionReadOrchestrator } from '../domain/usecases/transaction-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.TRANSACTION.split('-').join(' ')} - read`)
|
|
@Controller(`v1/${MODULE_NAME.TRANSACTION}`)
|
|
@Public(false)
|
|
@ApiBearerAuth('JWT')
|
|
export class TransactionReadController {
|
|
constructor(private orchestrator: TransactionReadOrchestrator) {}
|
|
|
|
@Get()
|
|
@Pagination()
|
|
async index(
|
|
@Query() params: FilterTransactionDto,
|
|
): Promise<PaginationResponse<TransactionEntity>> {
|
|
return await this.orchestrator.index(params);
|
|
}
|
|
|
|
@Get(':id')
|
|
async detail(@Param('id') id: string): Promise<TransactionEntity> {
|
|
return await this.orchestrator.detail(id);
|
|
}
|
|
|
|
@Public(true)
|
|
@Get('dummy/:id')
|
|
async calculate(@Param('id') id: string): Promise<string> {
|
|
this.orchestrator.dummyCalculate(id);
|
|
return 'OK';
|
|
}
|
|
|
|
@Public(true)
|
|
@Get('dummy2/calculate')
|
|
async calculateAll(): Promise<string> {
|
|
this.orchestrator.calculatePrice();
|
|
return 'OK';
|
|
}
|
|
}
|