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

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

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