mirror of https://github.com/usbharu/Hideout.git
Merge pull request #562 from usbharu/subscriber
Subscriberの初期化をinit関数でするように
This commit is contained in:
commit
4dcec9e806
|
@ -7,11 +7,10 @@ import org.springframework.stereotype.Component
|
|||
|
||||
@Component
|
||||
class RegisterLocalUserSetHomeTimelineSubscriber(
|
||||
domainEventSubscriber: DomainEventSubscriber,
|
||||
private val domainEventSubscriber: DomainEventSubscriber,
|
||||
private val userRegisterHomeTimelineApplicationService: UserRegisterHomeTimelineApplicationService
|
||||
) :
|
||||
Subscriber {
|
||||
init {
|
||||
) : Subscriber {
|
||||
override fun init() {
|
||||
domainEventSubscriber.subscribe<UserDetailEventBody>(UserDetailEvent.CREATE.eventName) {
|
||||
userRegisterHomeTimelineApplicationService.execute(
|
||||
RegisterHomeTimeline(it.body.getUserDetail().id),
|
||||
|
|
|
@ -9,11 +9,11 @@ import org.springframework.stereotype.Component
|
|||
|
||||
@Component
|
||||
class RegisterTimelineSetTimelineStoreSubscriber(
|
||||
domainEventSubscriber: DomainEventSubscriber,
|
||||
private val domainEventSubscriber: DomainEventSubscriber,
|
||||
private val setTimelineToTimelineStoreApplicationService: SetTimelineToTimelineStoreApplicationService
|
||||
) :
|
||||
Subscriber {
|
||||
init {
|
||||
) : Subscriber {
|
||||
|
||||
override fun init() {
|
||||
domainEventSubscriber.subscribe<TimelineEventBody>(TimelineEvent.CREATE.eventName) {
|
||||
setTimelineToTimelineStoreApplicationService.execute(SetTimleineStore(it.body.getTimelineId()), Anonymous)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
package dev.usbharu.hideout.core.application.domainevent.subscribers
|
||||
|
||||
interface Subscriber
|
||||
interface Subscriber {
|
||||
fun init()
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ import org.springframework.boot.ApplicationRunner
|
|||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class SubscriberRunner(subscribers: List<Subscriber>) : ApplicationRunner {
|
||||
class SubscriberRunner(private val subscribers: List<Subscriber>) : ApplicationRunner {
|
||||
override fun run(args: ApplicationArguments?) {
|
||||
subscribers.forEach { it.init() }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ import org.springframework.stereotype.Component
|
|||
@Component
|
||||
class TimelinePostCreateSubscriber(
|
||||
private val timelineAddPostApplicationService: TimelineAddPostApplicationService,
|
||||
domainEventSubscriber: DomainEventSubscriber,
|
||||
private val domainEventSubscriber: DomainEventSubscriber,
|
||||
) : Subscriber {
|
||||
init {
|
||||
override fun init() {
|
||||
domainEventSubscriber.subscribe<PostEventBody>(PostEvent.CREATE.eventName) {
|
||||
timelineAddPostApplicationService.execute(AddPost(it.body.getPostId()), Anonymous)
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ class TimelineRelationshipFollowSubscriber(
|
|||
private val userAddTimelineRelationshipApplicationService: UserAddTimelineRelationshipApplicationService,
|
||||
private val idGenerateService: IdGenerateService,
|
||||
private val userDetailRepository: UserDetailRepository,
|
||||
domainEventSubscriber: DomainEventSubscriber
|
||||
private val domainEventSubscriber: DomainEventSubscriber
|
||||
) : Subscriber {
|
||||
|
||||
init {
|
||||
override fun init() {
|
||||
domainEventSubscriber.subscribe<RelationshipEventBody>(RelationshipEvent.FOLLOW.eventName) {
|
||||
val relationship = it.body.getRelationship()
|
||||
val userDetail = userDetailRepository.findByActorId(relationship.actorId.id)
|
||||
|
|
Loading…
Reference in New Issue