| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 32 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { Controller, Inject, UseGuards, Get, Query } from '@nestjs/common'; |
||
| 2 | import { AuthGuard } from '@nestjs/passport'; |
||
| 3 | import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger'; |
||
| 4 | import { ContactView } from 'src/Application/Contact/View/ContactView'; |
||
| 5 | import { IQueryBus } from 'src/Application/IQueryBus'; |
||
| 6 | import { GetContactsQuery } from 'src/Application/Contact/Query/GetContactsQuery'; |
||
| 7 | import { RolesGuard } from 'src/Infrastructure/HumanResource/User/Security/RolesGuard'; |
||
| 8 | import { UserRole } from 'src/Domain/HumanResource/User/User.entity'; |
||
| 9 | import { Roles } from 'src/Infrastructure/HumanResource/User/Decorator/Roles'; |
||
| 10 | import { PaginationDTO } from 'src/Infrastructure/Common/DTO/PaginationDTO'; |
||
| 11 | import { Pagination } from 'src/Application/Common/Pagination'; |
||
| 12 | |||
| 13 | @Controller('contacts') |
||
| 14 | @ApiTags('Contact') |
||
| 15 | @ApiBearerAuth() |
||
| 16 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
| 17 | export class GetContactsAction { |
||
| 18 | constructor( |
||
| 19 | @Inject('IQueryBus') |
||
| 20 | private readonly queryBus: IQueryBus |
||
| 21 | ) {} |
||
| 22 | |||
| 23 | @Get() |
||
| 24 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE) |
||
| 25 | @ApiOperation({ summary: 'Get all contacts' }) |
||
| 26 | public async index( |
||
| 27 | @Query() pagination: PaginationDTO |
||
| 28 | ): Promise<Pagination<ContactView>> { |
||
| 29 | return await this.queryBus.execute(new GetContactsQuery(pagination.page)); |
||
| 30 | } |
||
| 31 | } |
||
| 32 |