Total Complexity | 2 |
Complexity/F | 2 |
Lines of Code | 50 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { |
||
2 | Body, |
||
3 | Post, |
||
4 | Controller, |
||
5 | Inject, |
||
6 | BadRequestException, |
||
7 | UseGuards, |
||
8 | UploadedFile, |
||
9 | UseInterceptors |
||
10 | } from '@nestjs/common'; |
||
11 | import {FileInterceptor} from '@nestjs/platform-express'; |
||
12 | import {AuthGuard} from '@nestjs/passport'; |
||
13 | import { |
||
14 | ApiUseTags, |
||
15 | ApiBearerAuth, |
||
16 | ApiOperation, |
||
17 | ApiImplicitFile |
||
18 | } from '@nestjs/swagger'; |
||
19 | import {ICommandBus} from 'src/Application/ICommandBus'; |
||
20 | import {Roles} from 'src/Infrastructure/User/Decorator/Roles'; |
||
21 | import {RolesGuard} from 'src/Infrastructure/User/Security/RolesGuard'; |
||
22 | import {UserRole} from 'src/Domain/User/User.entity'; |
||
23 | import {PayStubDTO} from '../DTO/PayStubDTO'; |
||
24 | |||
25 | @Controller('pay_stubs') |
||
26 | @ApiUseTags('Accounting') |
||
27 | @ApiBearerAuth() |
||
28 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
29 | export class CreatePayStubAction { |
||
30 | constructor( |
||
31 | @Inject('ICommandBus') |
||
32 | private readonly commandBus: ICommandBus |
||
33 | ) {} |
||
34 | |||
35 | @Post() |
||
36 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE) |
||
37 | @UseInterceptors(FileInterceptor('file')) |
||
38 | @ApiOperation({title: 'Create new paystub'}) |
||
39 | @ApiImplicitFile({ |
||
40 | name: 'file', |
||
41 | required: true |
||
42 | }) |
||
43 | public async index(@UploadedFile() file) { |
||
44 | try { |
||
45 | } catch (e) { |
||
46 | throw new BadRequestException(e.message); |
||
47 | } |
||
48 | } |
||
49 | } |
||
50 |