Passed
Pull Request — master (#210)
by Nicolas
01:41
created

server/src/Infrastructure/HumanResource/Leave/Action/GetOnLeaveUsersAction.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 31
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 26
mnd 0
bc 0
fnc 1
dl 0
loc 31
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A GetOnLeaveUsersAction.index 0 7 1
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 { GetOnLeaveUsersQuery } from 'src/Application/HumanResource/Leave/Query/GetOnLeaveUsersQuery';
9
import { OnLeaveUserView } from "src/Application/HumanResource/Leave/View/OnLeaveUserView";
10
11
@Controller('on-leave')
12
@ApiTags('Human Resource')
13
@ApiBearerAuth()
14
@UseGuards(AuthGuard('bearer'), RolesGuard)
15
export class GetOnLeaveUsersAction {
16
  constructor(
17
    @Inject('IQueryBus')
18
    private readonly queryBus: IQueryBus
19
  ) {
20
  }
21
22
  @Get()
23
  @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE)
24
  @ApiOperation({summary: 'Get today on leave users'})
25
  public async index(): Promise<Array<OnLeaveUserView>> {
26
    return await this.queryBus.execute(
27
      new GetOnLeaveUsersQuery()
28
    );
29
  }
30
}
31