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

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

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