import { Controller, Get, Param, Query } from '@nestjs/common';
import { FilterItemCategoryDto } from './dto/filter-item-category.dto';
import { Pagination } from 'src/core/response';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { ItemCategoryEntity } from '../domain/entities/item-category.entity';
import { ItemCategoryReadOrchestrator } from '../domain/usecases/item-category-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.ITEM_CATEGORY.split('-').join(' ')} - read`)
@Controller(`v1/${MODULE_NAME.ITEM_CATEGORY}`)
@Public(false)
@ApiBearerAuth('JWT')
export class ItemCategoryReadController {
  constructor(private orchestrator: ItemCategoryReadOrchestrator) {}

  @Get()
  @Pagination()
  async index(
    @Query() params: FilterItemCategoryDto,
  ): Promise<PaginationResponse<ItemCategoryEntity>> {
    return await this.orchestrator.index(params);
  }

  @Get(':id')
  async detail(@Param('id') id: string): Promise<ItemCategoryEntity> {
    return await this.orchestrator.detail(id);
  }
}
