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 { SchoolView } from 'src/Application/School/View/SchoolView'; |
||
5 | import { IQueryBus } from 'src/Application/IQueryBus'; |
||
6 | import { GetSchoolsQuery } from 'src/Application/School/Query/GetSchoolsQuery'; |
||
7 | import { Pagination } from 'src/Application/Common/Pagination'; |
||
8 | import { PaginationDTO } from 'src/Infrastructure/Common/DTO/PaginationDTO'; |
||
9 | import { RolesGuard } from 'src/Infrastructure/User/Security/RolesGuard'; |
||
10 | import { Roles } from 'src/Infrastructure/User/Decorator/Roles'; |
||
11 | import { UserRole } from 'src/Domain/User/User.entity'; |
||
12 | |||
13 | @Controller('schools') |
||
14 | @ApiTags('School') |
||
15 | @ApiBearerAuth() |
||
16 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
17 | export class GetSchoolsAction { |
||
18 | constructor( |
||
19 | @Inject('IQueryBus') |
||
20 | private readonly queryBus: IQueryBus |
||
21 | ) {} |
||
22 | |||
23 | @Get() |
||
24 | @Roles(UserRole.PHOTOGRAPHER) |
||
25 | @ApiOperation({summary: 'Get all schools'}) |
||
26 | public async index( |
||
27 | @Query() { page }: PaginationDTO |
||
28 | ): Promise<Pagination<SchoolView>> { |
||
29 | return await this.queryBus.execute(new GetSchoolsQuery(page)); |
||
30 | } |
||
31 | } |
||
32 |