Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 34 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { Controller, Inject, UseGuards, Get, Query } 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 { User, UserRole } from 'src/Domain/HumanResource/User/User.entity'; |
||
7 | import { Roles } from 'src/Infrastructure/HumanResource/User/Decorator/Roles'; |
||
8 | import { LeavesSummaryView } from 'src/Application/HumanResource/LeavesSummary/View/LeavesSummaryView'; |
||
9 | import { GetYearlyLeavesSummaryQuery } from 'src/Application/HumanResource/LeavesSummary/Query/GetYearlyLeavesSummaryQuery'; |
||
10 | import { Pagination } from 'src/Application/Common/Pagination'; |
||
11 | import { LoggedUser } from '../../User/Decorator/LoggedUser'; |
||
12 | |||
13 | @Controller('leaves-summary') |
||
14 | @ApiTags('Human Resource') |
||
15 | @ApiBearerAuth() |
||
16 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
17 | export class GetYearlyLeavesSummaryAction { |
||
18 | constructor( |
||
19 | @Inject('IQueryBus') |
||
20 | private readonly queryBus: IQueryBus |
||
21 | ) {} |
||
22 | |||
23 | @Get() |
||
24 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE) |
||
25 | @ApiOperation({ summary: 'Get yearly leaves summary' }) |
||
26 | public async index( |
||
27 | @LoggedUser() user: User |
||
28 | ): Promise<Pagination<LeavesSummaryView>> { |
||
29 | return await this.queryBus.execute( |
||
30 | new GetYearlyLeavesSummaryQuery(user.getId(), null) |
||
31 | ); |
||
32 | } |
||
33 | } |
||
34 |