Total Complexity | 2 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import { |
||
17 | |||
18 | @Controller('users/savings-records') |
||
19 | @ApiTags('Human Resource') |
||
20 | @ApiBearerAuth() |
||
21 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
22 | export class IncreaseUserSavingsRecordAction { |
||
23 | constructor( |
||
24 | @Inject('ICommandBus') |
||
25 | private readonly commandBus: ICommandBus |
||
26 | ) {} |
||
27 | |||
28 | @Post('increase') |
||
29 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE) |
||
30 | @ApiOperation({ summary: 'Increase user savings record' }) |
||
31 | public async index( |
||
32 | @Body() { userId, amount }: UserSavingsRecordDTO, |
||
33 | ) { |
||
34 | try { |
||
35 | const id = await this.commandBus.execute( |
||
36 | new IncreaseUserSavingsRecordCommand(amount, userId) |
||
37 | ); |
||
38 | |||
39 | return { id }; |
||
40 | } catch (e) { |
||
41 | throw new BadRequestException(e.message); |
||
42 | } |
||
45 |