import { Controller , Inject , UseGuards , Get , Query } from '@nestjs/common' ; import { AuthGuard } from '@nestjs/passport' ; import { ApiTags , ApiBearerAuth , ApiOperation } from '@nestjs/swagger' ; import { IQueryBus } from 'src/Application/IQueryBus' ; import { RolesGuard } from 'src/Infrastructure/HumanResource/User/Security/RolesGuard' ; import { UserRole } from 'src/Domain/HumanResource/User/User.entity' ; import { Roles } from 'src/Infrastructure/HumanResource/User/Decorator/Roles' ; import { LeaveRequestView } from 'src/Application/HumanResource/Leave/View/LeaveRequestView' ; import { GetLeaveRequestsQuery } from 'src/Application/HumanResource/Leave/Query/GetLeaveRequestsQuery' ; import { PaginationDTO } from 'src/Infrastructure/Common/DTO/PaginationDTO' ; import { Pagination } from 'src/Application/Common/Pagination' ; import { Status } from 'src/Domain/HumanResource/Leave/LeaveRequest.entity' ; @ Controller ( 'leaves' ) @ ApiTags ( 'Human Resource' ) @ ApiBearerAuth ( ) @ UseGuards ( AuthGuard ( 'bearer' ) , RolesGuard ) export class GetLeavesAction { constructor ( @ Inject ( 'IQueryBus' ) private readonly queryBus ) { } @ Get ( ) @ Roles ( UserRole . COOPERATOR , UserRole . EMPLOYEE ) @ ApiOperation ( { summary : 'Get all leaves' } ) public async index ( @ Query ( ) pagination ) { return await this . queryBus . execute ( new GetLeaveRequestsQuery ( pagination . page , Status . ACCEPTED ) ) ; } }