Total Complexity | 2 |
Complexity/F | 2 |
Lines of Code | 39 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { |
||
2 | Get, |
||
3 | Controller, |
||
4 | Inject, |
||
5 | BadRequestException, |
||
6 | UseGuards |
||
7 | } from '@nestjs/common'; |
||
8 | import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger'; |
||
9 | import { AuthGuard } from '@nestjs/passport'; |
||
10 | import { UserRole } from 'src/Domain/HumanResource/User/User.entity'; |
||
11 | import { RolesGuard } from 'src/Infrastructure/HumanResource/User/Security/RolesGuard'; |
||
12 | import { Roles } from 'src/Infrastructure/HumanResource/User/Decorator/Roles'; |
||
13 | import { IQueryBus } from 'src/Application/IQueryBus'; |
||
14 | import { GetUsersSavingsRecordsBalanceQuery } from 'src/Application/HumanResource/Savings/Query/GetUsersSavingsRecordsBalanceQuery'; |
||
15 | |||
16 | @Controller('users/savings-records') |
||
17 | @ApiTags('Human Resource') |
||
18 | @ApiBearerAuth() |
||
19 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
20 | export class GetUsersSavingsRecordsAction { |
||
21 | constructor( |
||
22 | @Inject('IQueryBus') |
||
23 | private readonly queryBus: IQueryBus |
||
24 | ) {} |
||
25 | |||
26 | @Get() |
||
27 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE) |
||
28 | @ApiOperation({ summary: 'Get users savings records balance' }) |
||
29 | public async index() { |
||
30 | try { |
||
31 | return await this.queryBus.execute( |
||
32 | new GetUsersSavingsRecordsBalanceQuery() |
||
33 | ); |
||
34 | } catch (e) { |
||
35 | throw new BadRequestException(e.message); |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 |