| Total Complexity | 4 |
| Complexity/F | 2 |
| Lines of Code | 32 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { ISchoolRepository } from 'src/Domain/School/Repository/ISchoolRepository'; |
||
| 2 | import { SchoolNotFoundException } from 'src/Domain/School/Exception/SchoolNotFoundException'; |
||
| 3 | import { IUserRepository } from 'src/Domain/User/Repository/IUserRepository'; |
||
| 4 | import { UserNotFoundException } from 'src/Domain/User/Exception/UserNotFoundException'; |
||
| 5 | import { User } from 'src/Domain/User/User.entity'; |
||
| 6 | import { School } from 'src/Domain/School/School.entity'; |
||
| 7 | |||
| 8 | export abstract class AbstractEventCommandHandler { |
||
| 9 | constructor( |
||
| 10 | private readonly schoolRepository: ISchoolRepository, |
||
| 11 | private readonly userRepository: IUserRepository |
||
| 12 | ) {} |
||
| 13 | |||
| 14 | protected async getUser(userId: string): Promise<User> { |
||
| 15 | const user = await this.userRepository.findOneById(userId); |
||
| 16 | if (!user) { |
||
| 17 | throw new UserNotFoundException(); |
||
| 18 | } |
||
| 19 | |||
| 20 | return user; |
||
| 21 | } |
||
| 22 | |||
| 23 | protected async getSchool(schoolId: string): Promise<School> { |
||
| 24 | const school = await this.schoolRepository.findOneById(schoolId); |
||
| 25 | if (!school) { |
||
| 26 | throw new SchoolNotFoundException(); |
||
| 27 | } |
||
| 28 | |||
| 29 | return school; |
||
| 30 | } |
||
| 31 | } |
||
| 32 |