-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee3f9eb
commit 8d097e1
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...es/main-api/src/main/java/com/whoz_in/main_api/command/badge/application/BadgeAttach.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,7 @@ | ||
package com.whoz_in.main_api.command.badge.application; | ||
|
||
import com.whoz_in.main_api.command.shared.application.Command; | ||
import java.util.UUID; | ||
|
||
public record BadgeAttach(UUID memberId, UUID badgeId) implements Command { | ||
} |
27 changes: 27 additions & 0 deletions
27
...-api/src/main/java/com/whoz_in/main_api/command/badge/application/BadgeAttachHandler.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 com.whoz_in.main_api.command.badge.application; | ||
|
||
import com.whoz_in.domain.badge.model.BadgeId; | ||
import com.whoz_in.domain.member.MemberRepository; | ||
import com.whoz_in.domain.member.model.Member; | ||
import com.whoz_in.domain.member.model.MemberId; | ||
import com.whoz_in.domain.shared.event.EventBus; | ||
import com.whoz_in.main_api.command.shared.application.CommandHandler; | ||
import com.whoz_in.main_api.shared.application.Handler; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Handler | ||
@RequiredArgsConstructor | ||
public class BadgeAttachHandler implements CommandHandler<BadgeAttach, Void> { | ||
private final MemberRepository repository; | ||
private final EventBus eventBus; | ||
|
||
@Transactional | ||
@Override | ||
public Void handle(BadgeAttach req) { | ||
Member member = repository.findByMemberId(new MemberId(req.memberId())).orElseThrow(); | ||
repository.addBadge(new MemberId(req.memberId()),new BadgeId(req.badgeId())); | ||
eventBus.publish(member.pullDomainEvents()); | ||
return null; | ||
} | ||
} |
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