| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 28 |
| 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 {ApiUseTags, 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 {HolidayView} from 'src/Application/HumanResource/Holiday/View/HolidayView'; |
||
| 9 | import {GetHolidaysQuery} from 'src/Application/HumanResource/Holiday/Query/GetHolidaysQuery'; |
||
| 10 | |||
| 11 | @Controller('holidays') |
||
| 12 | @ApiUseTags('Human Resource') |
||
| 13 | @ApiBearerAuth() |
||
| 14 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
| 15 | export class GetHolidaysAction { |
||
| 16 | constructor( |
||
| 17 | @Inject('IQueryBus') |
||
| 18 | private readonly queryBus: IQueryBus |
||
| 19 | ) {} |
||
| 20 | |||
| 21 | @Get() |
||
| 22 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE) |
||
| 23 | @ApiOperation({title: 'Get all holidays'}) |
||
| 24 | public async index(): Promise<HolidayView[]> { |
||
| 25 | return await this.queryBus.execute(new GetHolidaysQuery()); |
||
| 26 | } |
||
| 27 | } |
||
| 28 |