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

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

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