negyedik gyakorlat + megoldasok
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
const UserRepository = require('../../../infrastructure/repositories/UserRepository');
|
||||
|
||||
class GetAllUsersHandler {
|
||||
constructor() {
|
||||
this.userRepository = new UserRepository();
|
||||
}
|
||||
|
||||
async handle(query) {
|
||||
return await this.userRepository.findAll();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GetAllUsersHandler;
|
||||
@@ -0,0 +1,5 @@
|
||||
class GetAllUsersQuery {
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
module.exports = GetAllUsersQuery;
|
||||
@@ -0,0 +1,17 @@
|
||||
const UserRepository = require('../../../infrastructure/repositories/UserRepository');
|
||||
|
||||
class GetUserHandler {
|
||||
constructor() {
|
||||
this.userRepository = new UserRepository();
|
||||
}
|
||||
|
||||
async handle(query) {
|
||||
const user = await this.userRepository.findById(query.id);
|
||||
if (!user) {
|
||||
throw new Error('User nem található');
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GetUserHandler;
|
||||
@@ -0,0 +1,7 @@
|
||||
class GetUserQuery {
|
||||
constructor(id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GetUserQuery;
|
||||
Reference in New Issue
Block a user