-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/change notification permission] - 수신 활성화/비활성화 #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4ff9718
:sparkles: feat : add update notification status method
ekgns33 ce47f17
:sparkles: feat : add response codes
ekgns33 74f51e6
:sparkles: feat : implement updating notification allowed logic
ekgns33 a4c309c
:sparkles: feat : add fields to update request
ekgns33 7505f70
:sparkles: feat : implement upsert logic for device token
ekgns33 b0e0a4d
:sparkles: feat : add querying user notification status
ekgns33 ca72c0a
:sparkles: feat : add update-notification-allowed command
ekgns33 57e1591
:sparkles: feat : implement notification-permission update
ekgns33 af2e540
:hammer: chore : add db migration file
ekgns33 06032c1
:white_check_mark: test : add test-codes
ekgns33 ed95476
:hammer: chore : update dev-profile application.yml
ekgns33 44360ab
:white_check_mark: test : add test-setup-sql
ekgns33 e84ad04
:white_check_mark: test : add device-token test-setup-sql
ekgns33 cdb22d6
:white_check_mark: test : add user-device-update-usecase
ekgns33 97f5646
:white_check_mark: test : remove unnecessary mock setup
ekgns33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
13 changes: 13 additions & 0 deletions
13
src/main/java/org/runimo/runimo/user/controller/request/UpdateNotificationAllowedRequst.java
This file contains hidden or 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,13 @@ | ||
| package org.runimo.runimo.user.controller.request; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| @Schema(description = "알림 허용 여부 업데이트 요청") | ||
| public record UpdateNotificationAllowedRequst( | ||
| @Schema(description = "알림 허용 여부", example = "true") | ||
| boolean allowed, | ||
| String deviceToken, | ||
| String platform | ||
| ) { | ||
|
|
||
| } | ||
This file contains hidden or 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 hidden or 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
2 changes: 2 additions & 0 deletions
2
src/main/java/org/runimo/runimo/user/repository/UserDeviceTokenRepository.java
This file contains hidden or 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,10 +1,12 @@ | ||
| package org.runimo.runimo.user.repository; | ||
|
|
||
| import java.util.Optional; | ||
| import org.runimo.runimo.user.domain.UserDeviceToken; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| public interface UserDeviceTokenRepository extends JpaRepository<UserDeviceToken, Long> { | ||
|
|
||
| Optional<UserDeviceToken> findByUserId(Long userId); | ||
| } |
This file contains hidden or 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
...ain/java/org/runimo/runimo/user/service/dto/command/UpdateNotificationAllowedCommand.java
This file contains hidden or 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 org.runimo.runimo.user.service.dto.command; | ||
|
|
||
| import org.runimo.runimo.user.controller.request.UpdateNotificationAllowedRequst; | ||
| import org.runimo.runimo.user.domain.DevicePlatform; | ||
|
|
||
| public record UpdateNotificationAllowedCommand( | ||
| Long userId, | ||
| Boolean allowed, | ||
| String deviceToken, | ||
| DevicePlatform devicePlatform | ||
| ) { | ||
|
|
||
| public static UpdateNotificationAllowedCommand of(Long userId, | ||
| UpdateNotificationAllowedRequst request) { | ||
| return new UpdateNotificationAllowedCommand(userId, request.allowed(), | ||
| request.deviceToken(), DevicePlatform.fromString(request.platform())); | ||
| } | ||
|
|
||
|
|
||
| } |
13 changes: 13 additions & 0 deletions
13
src/main/java/org/runimo/runimo/user/service/dto/response/NotificationAllowedResponse.java
This file contains hidden or 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,13 @@ | ||
| package org.runimo.runimo.user.service.dto.response; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| @Schema(description = "알림 허용 여부 응답") | ||
| public record NotificationAllowedResponse( | ||
| @Schema(description = "사용자 ID", example = "1") | ||
| Long userId, | ||
| @Schema(description = "알림 허용 여부", example = "true") | ||
| boolean allowed | ||
| ) { | ||
|
|
||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/org/runimo/runimo/user/service/usecases/UpdateUserDetailUsecase.java
This file contains hidden or 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,8 @@ | ||
| package org.runimo.runimo.user.service.usecases; | ||
|
|
||
| import org.runimo.runimo.user.service.dto.command.UpdateNotificationAllowedCommand; | ||
|
|
||
| public interface UpdateUserDetailUsecase { | ||
|
|
||
| void updateUserNotificationAllowed(UpdateNotificationAllowedCommand command); | ||
| } |
44 changes: 44 additions & 0 deletions
44
src/main/java/org/runimo/runimo/user/service/usecases/UpdateUserDetailUsecaseImpl.java
This file contains hidden or 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,44 @@ | ||
| package org.runimo.runimo.user.service.usecases; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.runimo.runimo.user.domain.User; | ||
| import org.runimo.runimo.user.domain.UserDeviceToken; | ||
| import org.runimo.runimo.user.enums.UserHttpResponseCode; | ||
| import org.runimo.runimo.user.exception.UserException; | ||
| import org.runimo.runimo.user.repository.UserDeviceTokenRepository; | ||
| import org.runimo.runimo.user.service.UserFinder; | ||
| import org.runimo.runimo.user.service.dto.command.UpdateNotificationAllowedCommand; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class UpdateUserDetailUsecaseImpl implements UpdateUserDetailUsecase { | ||
|
|
||
| private final UserFinder userFinder; | ||
| private final UserDeviceTokenRepository userDeviceTokenRepository; | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public void updateUserNotificationAllowed(UpdateNotificationAllowedCommand command) { | ||
| UserDeviceToken token = userDeviceTokenRepository | ||
| .findByUserId(command.userId()) | ||
| .orElseGet(() -> createUserDeviceTokenIfNotExist(command)); | ||
| token.updateDeviceToken(command.deviceToken()); | ||
| token.updateNotificationAllowed(command.allowed()); | ||
ekgns33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| private UserDeviceToken createUserDeviceTokenIfNotExist( | ||
| UpdateNotificationAllowedCommand command) { | ||
| User user = userFinder.findUserById(command.userId()) | ||
| .orElseThrow(() -> UserException.of(UserHttpResponseCode.USER_NOT_FOUND)); | ||
|
|
||
| UserDeviceToken token = UserDeviceToken.builder() | ||
| .user(user) | ||
| .deviceToken(command.deviceToken()) | ||
| .platform(command.devicePlatform()) | ||
| .notificationAllowed(command.allowed()) | ||
| .build(); | ||
| return userDeviceTokenRepository.save(token); | ||
| } | ||
| } | ||
9 changes: 9 additions & 0 deletions
9
src/main/java/org/runimo/runimo/user/service/usecases/query/UserInfoQueryUsecase.java
This file contains hidden or 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 org.runimo.runimo.user.service.usecases.query; | ||
|
|
||
| import org.runimo.runimo.user.service.dto.response.NotificationAllowedResponse; | ||
|
|
||
| public interface UserInfoQueryUsecase { | ||
|
|
||
| NotificationAllowedResponse getUserNotificationAllowed(Long userId); | ||
|
|
||
| } |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/runimo/runimo/user/service/usecases/query/UserInfoQueryUsecaseImpl.java
This file contains hidden or 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,25 @@ | ||
| package org.runimo.runimo.user.service.usecases.query; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.runimo.runimo.user.enums.UserHttpResponseCode; | ||
| import org.runimo.runimo.user.exception.UserException; | ||
| import org.runimo.runimo.user.service.UserFinder; | ||
| import org.runimo.runimo.user.service.dto.response.NotificationAllowedResponse; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class UserInfoQueryUsecaseImpl implements UserInfoQueryUsecase { | ||
|
|
||
| private final UserFinder userFinder; | ||
|
|
||
| @Override | ||
| public NotificationAllowedResponse getUserNotificationAllowed(Long userId) { | ||
| if (userFinder.findUserById(userId).isEmpty()) { | ||
| throw UserException.of(UserHttpResponseCode.USER_NOT_FOUND); | ||
| } | ||
| var userDeviceToken = userFinder.findUserDeviceTokenByUserId(userId) | ||
| .orElseThrow(() -> UserException.of(UserHttpResponseCode.DEVICE_TOKEN_NOT_FOUND)); | ||
| return new NotificationAllowedResponse(userId, userDeviceToken.getNotificationAllowed()); | ||
| } | ||
| } |
This file contains hidden or 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
2 changes: 2 additions & 0 deletions
2
src/main/resources/db/migration/V202050709__add_unique_constraint_to_device_token.sql
This file contains hidden or 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,2 @@ | ||
| ALTER TABLE user_token | ||
| ADD CONSTRAINT uq_user_token_device_token UNIQUE (device_token); |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.