generated from CodelyTV/java-basic-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate register Student use case to command
- Loading branch information
1 parent
6f3da18
commit 34b9ecf
Showing
7 changed files
with
70 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...tion/register/RegisterStudentRequest.java → ...tion/register/RegisterStudentCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...mooc/main/tv/codely/mooc/students/application/register/RegisterStudentCommandHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package tv.codely.mooc.students.application.register; | ||
|
||
import tv.codely.mooc.students.domain.StudentEmail; | ||
import tv.codely.mooc.students.domain.StudentId; | ||
import tv.codely.mooc.students.domain.StudentName; | ||
import tv.codely.mooc.students.domain.StudentSurname; | ||
import tv.codely.shared.domain.Service; | ||
import tv.codely.shared.domain.bus.command.CommandHandler; | ||
|
||
@Service | ||
public final class RegisterStudentCommandHandler implements CommandHandler<RegisterStudentCommand> { | ||
private final StudentRegistrar registrar; | ||
|
||
public RegisterStudentCommandHandler(StudentRegistrar registrar) { | ||
this.registrar = registrar; | ||
} | ||
|
||
@Override | ||
public void handle(RegisterStudentCommand command) { | ||
StudentId id = new StudentId(command.id()); | ||
StudentName name = new StudentName(command.name()); | ||
StudentSurname surname = new StudentSurname(command.surname()); | ||
StudentEmail email = new StudentEmail(command.email()); | ||
|
||
registrar.register(id, name, surname, email); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/mooc/test/tv/codely/mooc/students/domain/StudentMother.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters