File tree 3 files changed +25
-2
lines changed
Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow
3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class Promise(
46
46
) : BaseTimeEntity() {
47
47
@PostPersist
48
48
fun createPromiseEvent () {
49
- Events .raise(PromiseRegisterEvent (this .id!! ))
49
+ Events .raise(PromiseRegisterEvent (this .id!! , this .mainUserId ))
50
50
}
51
51
fun updateTitle (title : String ) {
52
52
this .title = title
Original file line number Diff line number Diff line change @@ -4,4 +4,5 @@ import com.depromeet.whatnow.common.aop.event.DomainEvent
4
4
5
5
class PromiseRegisterEvent (
6
6
val promiseId : Long ,
7
+ val userId : Long ,
7
8
) : DomainEvent()
Original file line number Diff line number Diff line change 1
1
package com.depromeet.whatnow.events.handler
2
2
3
- class PromiseRegisterEventHandler
3
+ import com.depromeet.whatnow.annotation.Handler
4
+ import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUser
5
+ import com.depromeet.whatnow.domains.promiseuser.service.PromiseUserDomainService
6
+ import com.depromeet.whatnow.events.domainEvent.PromiseRegisterEvent
7
+ import org.springframework.scheduling.annotation.Async
8
+ import org.springframework.transaction.event.TransactionPhase
9
+ import org.springframework.transaction.event.TransactionalEventListener
10
+
11
+ @Handler
12
+ class PromiseRegisterEventHandler (
13
+ val promiseUserDomainService : PromiseUserDomainService ,
14
+ ) {
15
+ @Async
16
+ @TransactionalEventListener(classes = [PromiseRegisterEvent ::class ], phase = TransactionPhase .AFTER_COMMIT )
17
+ fun handleRegisterPictureEvent (promiseRegisterEvent : PromiseRegisterEvent ) {
18
+ // 약속 등록 시 방장의 PromiseUser 생성하기
19
+ val promiseUser = PromiseUser (
20
+ promiseId = promiseRegisterEvent.promiseId,
21
+ userId = promiseRegisterEvent.userId,
22
+ )
23
+ promiseUserDomainService.createPromiseUser(promiseUser)
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments