59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import { Controller, Get, Param, Query } from '@nestjs/common';
|
|
import { FilterItemDto } from './dto/filter-item.dto';
|
|
import { Pagination } from 'src/core/response';
|
|
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
|
import { ItemEntity } from '../domain/entities/item.entity';
|
|
import { ItemReadOrchestrator } from '../domain/usecases/item-read.orchestrator';
|
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
|
import { ExcludePrivilege, Public } from 'src/core/guards';
|
|
import { ItemRateEntity } from '../../item-rate/domain/entities/item-rate.entity';
|
|
import { FilterItemRateDto } from '../../item-rate/infrastructure/dto/filter-item-rate.dto';
|
|
|
|
@ApiTags(`${MODULE_NAME.ITEM.split('-').join(' ')} - read`)
|
|
@Controller(`v1/${MODULE_NAME.ITEM}`)
|
|
@Public(false)
|
|
@ApiBearerAuth('JWT')
|
|
export class ItemReadController {
|
|
constructor(private orchestrator: ItemReadOrchestrator) {}
|
|
|
|
@Get()
|
|
@Pagination()
|
|
async index(
|
|
@Query() params: FilterItemDto,
|
|
): Promise<PaginationResponse<ItemEntity>> {
|
|
return await this.orchestrator.index(params);
|
|
}
|
|
|
|
@Get(':id')
|
|
async detail(@Param('id') id: string): Promise<ItemEntity> {
|
|
return await this.orchestrator.detail(id);
|
|
}
|
|
|
|
@Get(':id/rates')
|
|
@Pagination()
|
|
async indexRate(
|
|
@Query() params: FilterItemRateDto,
|
|
@Param('id') id: string,
|
|
): Promise<PaginationResponse<ItemRateEntity>> {
|
|
params.item_ids = [id];
|
|
return await this.orchestrator.indexRate(params);
|
|
}
|
|
}
|
|
|
|
@ApiTags(`Item Queue - Read`)
|
|
@Controller(`v1/item-queue`)
|
|
@Public(true)
|
|
export class ItemReadQueueController {
|
|
constructor(private orchestrator: ItemReadOrchestrator) {}
|
|
|
|
@Get()
|
|
@Pagination()
|
|
@ExcludePrivilege()
|
|
async indexQueue(
|
|
@Query() params: FilterItemDto,
|
|
): Promise<PaginationResponse<ItemEntity>> {
|
|
return await this.orchestrator.indexQueue(params);
|
|
}
|
|
}
|