-
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.
Merge pull request #237 from JNU-econovation/feat/remove-active-device
[FEAT] Active Device 삭제 기능
- Loading branch information
Showing
8 changed files
with
78 additions
and
8 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
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
14 changes: 14 additions & 0 deletions
14
modules/domain/src/main/java/com/whoz_in/domain/device/event/DeviceDeleted.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,14 @@ | ||
package com.whoz_in.domain.device.event; | ||
|
||
import com.whoz_in.domain.shared.event.DomainEvent; | ||
import java.util.UUID; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
public final class DeviceDeleted extends DomainEvent { | ||
|
||
private final UUID deviceId; | ||
|
||
} |
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
22 changes: 22 additions & 0 deletions
22
...n/java/com/whoz_in/api_query_jpa/device/active/event/ActiveDeviceDeletedEventHandler.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,22 @@ | ||
package com.whoz_in.api_query_jpa.device.active.event; | ||
|
||
import com.whoz_in.api_query_jpa.device.active.ActiveDeviceRepository; | ||
import com.whoz_in.main_api.shared.domain.device.active.event.DeviceDeletedEvent; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Component("ActiveDeviceDeletedEventHandler") | ||
@RequiredArgsConstructor | ||
public class ActiveDeviceDeletedEventHandler { | ||
|
||
private final ActiveDeviceRepository activeDeviceRepository; | ||
|
||
@Transactional | ||
@EventListener(DeviceDeletedEvent.class) | ||
public void handle(DeviceDeletedEvent event) { | ||
activeDeviceRepository.deleteById(event.deviceId()); | ||
} | ||
|
||
} |
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
10 changes: 10 additions & 0 deletions
10
.../main/java/com/whoz_in/main_api/shared/domain/device/active/event/DeviceDeletedEvent.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,10 @@ | ||
package com.whoz_in.main_api.shared.domain.device.active.event; | ||
|
||
import com.whoz_in.main_api.shared.event.ApplicationEvent; | ||
import java.util.UUID; | ||
|
||
public record DeviceDeletedEvent( | ||
UUID deviceId | ||
) | ||
implements ApplicationEvent { | ||
} |
20 changes: 20 additions & 0 deletions
20
...ava/com/whoz_in/main_api/shared/domain/device/active/event/DeviceDeletedEventHandler.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,20 @@ | ||
package com.whoz_in.main_api.shared.domain.device.active.event; | ||
|
||
import com.whoz_in.domain.device.event.DeviceDeleted; | ||
import com.whoz_in.main_api.shared.event.Events; | ||
import java.util.UUID; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class DeviceDeletedEventHandler { | ||
|
||
@TransactionalEventListener(DeviceDeleted.class) | ||
public void processDeviceDeletedEvent(DeviceDeleted event) { | ||
UUID deviceId = event.getDeviceId(); | ||
|
||
Events.raise(new DeviceDeletedEvent(deviceId)); | ||
} | ||
} |