-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
5 changed files
with
51 additions
and
79 deletions.
There are no files selected for viewing
47 changes: 0 additions & 47 deletions
47
...pplication/src/main/java/kr/flab/movieon/order/application/CreateOrderCommandHandler.java
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
...order-application/src/main/java/kr/flab/movieon/order/application/CreateOrderUsecase.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,30 @@ | ||
package kr.flab.movieon.order.application; | ||
|
||
import kr.flab.movieon.order.application.command.CreateOrderCommand; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.support.TransactionTemplate; | ||
|
||
@Service | ||
public final class CreateOrderUsecase { | ||
|
||
private final OrderCommandExecutor executor; | ||
private final TransactionTemplate transactionTemplate; | ||
private final ApplicationEventPublisher publisher; | ||
|
||
public CreateOrderUsecase(OrderCommandExecutor executor, | ||
TransactionTemplate transactionTemplate, | ||
ApplicationEventPublisher publisher) { | ||
this.executor = executor; | ||
this.transactionTemplate = transactionTemplate; | ||
this.publisher = publisher; | ||
} | ||
|
||
public String create(String accountId, CreateOrderCommand command) { | ||
var order = transactionTemplate.execute(status -> | ||
executor.create(accountId, command) | ||
); | ||
order.pollAllEvents().forEach(publisher::publishEvent); | ||
return order.getOrderKey(); | ||
} | ||
} |
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