import { Controller , Get , HttpCode , HttpStatus , Query , ValidationPipe , } from '@nestjs/common' ; import { ApiResponse , ApiTags } from '@nestjs/swagger' ; import { PageDto } from '../../common/dto/page.dto' ; import { RoleType } from '../../constants' ; import { ApiPageOkResponse , Auth , AuthUser , UUIDParam } from '../../decorators' ; import { TranslationService } from '../../shared/services/translation.service' ; import { UserDto } from './dtos/user.dto' ; import { UsersPageOptionsDto } from './dtos/users-page-options.dto' ; import { UserEntity } from './user.entity' ; import { UserService } from './user.service' ; @ Controller ( 'users' ) @ ApiTags ( 'users' ) export class UserController { constructor ( private userService , private readonly translationService ) { } @ Get ( 'admin' ) @ Auth ( [ RoleType . USER ] ) @ HttpCode ( HttpStatus . OK ) async admin ( @ AuthUser ( ) user ) { const translation = await this . translationService . translate ( 'keywords.admin' , { lang : 'en' , } ) ; return `${ translation } ${ user . firstName }` ; } @ Get ( ) @ Auth ( [ RoleType . USER ] ) @ HttpCode ( HttpStatus . OK ) @ ApiPageOkResponse ( { description : 'Get users list' , type : PageDto , } ) getUsers ( @ Query ( new ValidationPipe ( { transform : true } ) ) pageOptionsDto ) { return this . userService . getUsers ( pageOptionsDto ) ; } @ Get ( ':id' ) @ Auth ( [ RoleType . USER ] ) @ HttpCode ( HttpStatus . OK ) @ ApiResponse ( { status : HttpStatus . OK , description : 'Get users list' , type : UserDto , } ) getUser ( @ UUIDParam ( 'id' ) userId ) { return this . userService . getUser ( userId ) ; } }