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

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

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