From 604ced8311cdda3df2cf14ac3f23a0dca293ec2a Mon Sep 17 00:00:00 2001 From: bongsh0112 Date: Sat, 10 Feb 2024 10:07:12 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EC=9C=A0=EC=A0=80=20=EC=95=8C?= =?UTF-8?q?=EB=A6=BC=EC=88=98=EC=8B=A0=EC=97=AC=EB=B6=80=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20#155?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/user/controller/UserController.java | 8 +++++++ .../service/UpdateAlarmReceiveUseCase.java | 22 +++++++++++++++++++ .../domain/domains/user/domain/User.java | 5 +++++ 3 files changed, 35 insertions(+) create mode 100644 Api/src/main/java/tify/server/api/user/service/UpdateAlarmReceiveUseCase.java diff --git a/Api/src/main/java/tify/server/api/user/controller/UserController.java b/Api/src/main/java/tify/server/api/user/controller/UserController.java index 02243cd..b0d4829 100644 --- a/Api/src/main/java/tify/server/api/user/controller/UserController.java +++ b/Api/src/main/java/tify/server/api/user/controller/UserController.java @@ -54,6 +54,7 @@ import tify.server.api.user.service.RetrieveUserListUseCase; import tify.server.api.user.service.RetrieveUserOpinionUseCase; import tify.server.api.user.service.RetrieveUserReportUseCase; +import tify.server.api.user.service.UpdateAlarmReceiveUseCase; import tify.server.api.user.service.UpdateNeighborUseCase; import tify.server.api.user.service.UpdateUserExpoTokenUseCase; import tify.server.api.user.service.UpdateUserFavorUseCase; @@ -104,6 +105,7 @@ public class UserController { private final RetrieveUserOpinionUseCase retrieveUserOpinionUseCase; private final RetrieveNeighborFavorBoxUseCase retrieveNeighborFavorBoxUseCase; private final UpdateUserExpoTokenUseCase updateUserExpoTokenUseCase; + private final UpdateAlarmReceiveUseCase updateAlarmReceiveUseCase; @Operation(summary = "유저 정보 조회") @GetMapping("/{userId}") @@ -339,4 +341,10 @@ public void patchExpoToken( @RequestParam Long userId, @RequestBody @Valid PatchExpoTokenRequest request) { updateUserExpoTokenUseCase.execute(userId, request); } + + @Operation(summary = "유저의 알림 수신 여부를 변경합니다.") + @PatchMapping("/alarm/receive") + public void patchAlarmReceive() { + updateAlarmReceiveUseCase.execute(); + } } diff --git a/Api/src/main/java/tify/server/api/user/service/UpdateAlarmReceiveUseCase.java b/Api/src/main/java/tify/server/api/user/service/UpdateAlarmReceiveUseCase.java new file mode 100644 index 0000000..b32e6a1 --- /dev/null +++ b/Api/src/main/java/tify/server/api/user/service/UpdateAlarmReceiveUseCase.java @@ -0,0 +1,22 @@ +package tify.server.api.user.service; + + +import lombok.RequiredArgsConstructor; +import org.springframework.transaction.annotation.Transactional; +import tify.server.api.config.security.SecurityUtils; +import tify.server.core.annotation.UseCase; +import tify.server.domain.domains.user.adaptor.UserAdaptor; +import tify.server.domain.domains.user.domain.User; + +@UseCase +@RequiredArgsConstructor +public class UpdateAlarmReceiveUseCase { + + private final UserAdaptor userAdaptor; + + @Transactional + public void execute() { + User currentUser = userAdaptor.query(SecurityUtils.getCurrentUserId()); + currentUser.updateUserReceiveAlarm(); + } +} diff --git a/Domain/src/main/java/tify/server/domain/domains/user/domain/User.java b/Domain/src/main/java/tify/server/domain/domains/user/domain/User.java index 3161785..c19d177 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/domain/User.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/domain/User.java @@ -85,6 +85,7 @@ public User(OauthInfo oauthInfo) { this.oauthInfo = oauthInfo; } + // TODO : 온보딩 시 푸시알림 true / false 선택 가능하도록 public void onBoarding( String username, String userId, @@ -125,4 +126,8 @@ public void updateOnBoardingStatus(UserOnBoardingStatus userOnBoardingStatus) { public void updateUserExpoToken(String expoToken) { this.expoToken = expoToken; } + + public void updateUserReceiveAlarm() { + this.receiveAlarm = !this.receiveAlarm; + } }