Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 27 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { Controller, Inject, UseGuards, Get } from '@nestjs/common'; |
||
2 | import { AuthGuard } from '@nestjs/passport'; |
||
3 | import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger'; |
||
4 | import { IQueryBus } from 'src/Application/IQueryBus'; |
||
5 | import { RolesGuard } from 'src/Infrastructure/HumanResource/User/Security/RolesGuard'; |
||
6 | import { UserRole } from 'src/Domain/HumanResource/User/User.entity'; |
||
7 | import { Roles } from 'src/Infrastructure/HumanResource/User/Decorator/Roles'; |
||
8 | import { GetPendingLeaveRequestsCountQuery } from 'src/Application/HumanResource/Leave/Query/GetPendingLeaveRequestsCountQuery'; |
||
9 | |||
10 | @Controller('leave-requests/pending-count') |
||
11 | @ApiTags('Human Resource') |
||
12 | @ApiBearerAuth() |
||
13 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
14 | export class GetPendingLeaveRequestsCountAction { |
||
15 | constructor( |
||
16 | @Inject('IQueryBus') |
||
17 | private readonly queryBus: IQueryBus |
||
18 | ) {} |
||
19 | |||
20 | @Get() |
||
21 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE) |
||
22 | @ApiOperation({ summary: 'Get count of pending leave requests' }) |
||
23 | public async index(): Promise<number> { |
||
24 | return await this.queryBus.execute(new GetPendingLeaveRequestsCountQuery()); |
||
25 | } |
||
26 | } |
||
27 |