| Total Complexity | 2 | 
| Complexity/F | 2 | 
| Lines of Code | 34 | 
| Function Count | 1 | 
| Duplicated Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | import {QueryHandler} from '@nestjs/cqrs'; | ||
| 2 | import {Inject} from '@nestjs/common'; | ||
| 3 | import {GetUsersQuery} from './GetUsersQuery'; | ||
| 4 | import {UserView} from '../View/UserView'; | ||
| 5 | import {IUserRepository} from 'src/Domain/HumanResource/User/Repository/IUserRepository'; | ||
| 6 | |||
| 7 | @QueryHandler(GetUsersQuery) | ||
| 8 | export class GetUsersQueryHandler { | ||
| 9 | constructor( | ||
| 10 |     @Inject('IUserRepository') | ||
| 11 | private readonly userRepository: IUserRepository | ||
| 12 |   ) {} | ||
| 13 | |||
| 14 |   public async execute(query: GetUsersQuery): Promise<UserView[]> { | ||
| 15 | const users = await this.userRepository.findUsers(query.withAccountant); | ||
| 16 | const userViews: UserView[] = []; | ||
| 17 | |||
| 18 |     for (const user of users) { | ||
| 19 | userViews.push( | ||
| 20 | new UserView( | ||
| 21 | user.getId(), | ||
| 22 | user.getFirstName(), | ||
| 23 | user.getLastName(), | ||
| 24 | user.getEmail(), | ||
| 25 | user.getRole(), | ||
| 26 | user.getEntryDate() | ||
| 27 | ) | ||
| 28 | ); | ||
| 29 | } | ||
| 30 | |||
| 31 | return userViews; | ||
| 32 | } | ||
| 33 | } | ||
| 34 |