-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(Alert): Alert 도메인 구현 * feat(StringToDateTimeConverter): StringToDateTimeConverter 구현 * feat(Create_alert.sql): Alert 생성 SQL문 작성 * feat(TimeConfig): 시간을 서울로 지정하여 Clock Bean 등록 * feat(AlertService): AlertService 구현 * feat(AlertService): AlertService 에 필요한 port와 repository 구현 * refactor(MessageEventPort): 정해진 시간에 Message 를 보내니 MessageEventPort 가 더 적합한 이름이라 판단 * fix(StringToDateTimeConverter): 밀리초가 있는 경우 정상 파싱되지 않던 케이스 수정 * test: 예약 알림 인수테스트 작석 생성, 조회, 삭제 테스트 작성 * feat: Admin을 통하여 Alert를 등록하고, 삭제하고, 조회하도록 구현 * fix(StaffUpdater, UserUpdater): 정상동작하지 않는 updater deprecated 표기 * fix: LocalDateTime에서 Clock을 사용하도록 수정 * fix: MICROS 정밀도 무시 * fix(StringToDateTimeConverter): Milli-second 부분은 6자리 까지만 지원
- Loading branch information
1 parent
935c6bd
commit e5c1d67
Showing
40 changed files
with
1,046 additions
and
17 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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/kustacks/kuring/admin/adapter/in/web/dto/AdminAlertResponse.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.kustacks.kuring.admin.adapter.in.web.dto; | ||
|
||
import com.kustacks.kuring.alert.domain.AlertStatus; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record AdminAlertResponse( | ||
Long id, | ||
String title, | ||
String content, | ||
AlertStatus status, | ||
LocalDateTime wakeTime | ||
) { | ||
public static AdminAlertResponse of( | ||
Long id, String title, String content, | ||
AlertStatus status, LocalDateTime alertTime | ||
) { | ||
return new AdminAlertResponse(id, title, content, status, alertTime); | ||
} | ||
}; |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/kustacks/kuring/admin/adapter/out/event/AdminAdminAlertEventAdapter.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,23 @@ | ||
package com.kustacks.kuring.admin.adapter.out.event; | ||
|
||
import com.kustacks.kuring.admin.application.port.out.AdminAlertEventPort; | ||
import com.kustacks.kuring.alert.adapter.in.event.dto.AlertCreateEvent; | ||
import com.kustacks.kuring.alert.adapter.in.event.dto.AlertDeleteEvent; | ||
import com.kustacks.kuring.common.domain.Events; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Component | ||
public class AdminAdminAlertEventAdapter implements AdminAlertEventPort { | ||
|
||
@Override | ||
public void addAlertSchedule(String title, String content, LocalDateTime alertTime) { | ||
Events.raise(new AlertCreateEvent(title, content, alertTime)); | ||
} | ||
|
||
@Override | ||
public void cancelAlertSchedule(Long id) { | ||
Events.raise(new AlertDeleteEvent(id)); | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
src/main/java/com/kustacks/kuring/admin/application/port/in/AdminQueryUseCase.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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package com.kustacks.kuring.admin.application.port.in; | ||
|
||
import com.kustacks.kuring.admin.adapter.in.web.dto.AdminAlertResponse; | ||
import com.kustacks.kuring.user.application.port.in.dto.AdminFeedbacksResult; | ||
|
||
import java.util.List; | ||
|
||
public interface AdminQueryUseCase { | ||
List<AdminFeedbacksResult> lookupFeedbacks(int page, int size); | ||
|
||
List<AdminAlertResponse> lookupAlerts(int page, int size); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/kustacks/kuring/admin/application/port/out/AdminAlertEventPort.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,9 @@ | ||
package com.kustacks.kuring.admin.application.port.out; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public interface AdminAlertEventPort { | ||
void addAlertSchedule(String title, String content, LocalDateTime alertTime); | ||
|
||
void cancelAlertSchedule(Long id); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/kustacks/kuring/admin/application/port/out/AdminAlertQueryPort.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,9 @@ | ||
package com.kustacks.kuring.admin.application.port.out; | ||
|
||
import com.kustacks.kuring.alert.domain.Alert; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
public interface AdminAlertQueryPort { | ||
Page<Alert> findAllAlertByPageRequest(Pageable pageable); | ||
} |
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
34 changes: 34 additions & 0 deletions
34
src/main/java/com/kustacks/kuring/alert/adapter/in/event/AlertCommandEventListener.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,34 @@ | ||
package com.kustacks.kuring.alert.adapter.in.event; | ||
|
||
import com.kustacks.kuring.alert.adapter.in.event.dto.AlertCreateEvent; | ||
import com.kustacks.kuring.alert.adapter.in.event.dto.AlertDeleteEvent; | ||
import com.kustacks.kuring.alert.application.port.in.AlertCommandUseCase; | ||
import com.kustacks.kuring.alert.application.port.in.dto.AlertCreateCommand; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class AlertCommandEventListener { | ||
|
||
private final AlertCommandUseCase alertCommandUseCase; | ||
|
||
@EventListener | ||
public void createAlert( | ||
AlertCreateEvent event | ||
) { | ||
AlertCreateCommand command = new AlertCreateCommand( | ||
event.title(), event.content(), event.alertTime() | ||
); | ||
|
||
alertCommandUseCase.addAlertSchedule(command); | ||
} | ||
|
||
@EventListener | ||
public void cancelAlert( | ||
AlertDeleteEvent event | ||
) { | ||
alertCommandUseCase.cancelAlertSchedule(event.id()); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/kustacks/kuring/alert/adapter/in/event/dto/AlertCreateEvent.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.kustacks.kuring.alert.adapter.in.event.dto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record AlertCreateEvent( | ||
String title, | ||
String content, | ||
LocalDateTime alertTime | ||
) { | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/kustacks/kuring/alert/adapter/in/event/dto/AlertDeleteEvent.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,6 @@ | ||
package com.kustacks.kuring.alert.adapter.in.event.dto; | ||
|
||
public record AlertDeleteEvent( | ||
Long id | ||
) { | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/kustacks/kuring/alert/adapter/in/web/AlertCommandApiV2.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,47 @@ | ||
package com.kustacks.kuring.alert.adapter.in.web; | ||
|
||
import com.google.firebase.database.annotations.NotNull; | ||
import com.kustacks.kuring.alert.adapter.in.web.dto.AlertCreateRequest; | ||
import com.kustacks.kuring.alert.application.port.in.AlertCommandUseCase; | ||
import com.kustacks.kuring.alert.application.port.in.dto.AlertCreateCommand; | ||
import com.kustacks.kuring.common.annotation.RestWebAdapter; | ||
import com.kustacks.kuring.common.utils.converter.StringToDateTimeConverter; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
|
||
@Tag(name = "Alert-Command", description = "알림 에약") | ||
@Validated | ||
@RequiredArgsConstructor | ||
@RestWebAdapter(path = "/api/v2/alerts") | ||
public class AlertCommandApiV2 { | ||
|
||
private final AlertCommandUseCase alertCommandUseCase; | ||
|
||
@Operation(summary = "예약 알림 등록", description = "서버에 예약 알림을 등록한다") | ||
@PostMapping | ||
public void createAlert( | ||
@RequestBody AlertCreateRequest request | ||
) { | ||
AlertCreateCommand command = new AlertCreateCommand( | ||
request.title(), request.content(), | ||
StringToDateTimeConverter.convert(request.alertTime()) | ||
); | ||
|
||
alertCommandUseCase.addAlertSchedule(command); | ||
} | ||
|
||
@Operation(summary = "예약 알림 삭제", description = "서버에 예약되어 있는 특정 알림을 삭제한다") | ||
@DeleteMapping("/{id}") | ||
public void cancelAlert( | ||
@Parameter(description = "알림 아이디") @NotNull @PathVariable Long id | ||
) { | ||
alertCommandUseCase.cancelAlertSchedule(id); | ||
} | ||
} |
Oops, something went wrong.