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

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

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