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

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

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