Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 29 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {Controller, Inject, Get, UseGuards, Query} from '@nestjs/common'; |
||
2 | import {AuthGuard} from '@nestjs/passport'; |
||
3 | import {ApiUseTags, ApiOperation, ApiBearerAuth} from '@nestjs/swagger'; |
||
4 | import {UserView} from 'src/Application/HumanResource/User/View/UserView'; |
||
5 | import {IQueryBus} from 'src/Application/IQueryBus'; |
||
6 | import {GetUsersQuery} from 'src/Application/HumanResource/User/Query/GetUsersQuery'; |
||
7 | import {FiltersDTO} from '../DTO/FiltersDTO'; |
||
8 | import {Roles} from '../Decorator/Roles'; |
||
9 | import {RolesGuard} from '../Security/RolesGuard'; |
||
10 | import {UserRole} from 'src/Domain/HumanResource/User/User.entity'; |
||
11 | |||
12 | @Controller('users') |
||
13 | @ApiUseTags('User') |
||
14 | @ApiBearerAuth() |
||
15 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
16 | export class GetUsersAction { |
||
17 | constructor( |
||
18 | @Inject('IQueryBus') |
||
19 | private readonly queryBus: IQueryBus |
||
20 | ) {} |
||
21 | |||
22 | @Get() |
||
23 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE) |
||
24 | @ApiOperation({title: 'Get all users'}) |
||
25 | public async index(@Query() query: FiltersDTO): Promise<UserView[]> { |
||
26 | return await this.queryBus.execute(new GetUsersQuery(query.withAccountant)); |
||
27 | } |
||
28 | } |
||
29 |