-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/user device token] - 알림을 위한 디바이스 토큰수집 #104
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 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9298972
:sparkles: feat : add `device_token`, `device_platform` to UserSignup…
ekgns33 2acf56c
:sparkles: feat : add UserDeviceToken entity
ekgns33 120c145
:sparkles: feat : implement saving user-device-token when register
ekgns33 dd6c007
:hammer: ddl : update `user_token` table; enhance columns
ekgns33 653ab2d
:sparkles: feat : add DeviceTokenDto
ekgns33 6486561
:recycle: refactor : refactor saving device-token logic
ekgns33 c23dc5a
:white_check_mark: test : add test-codes for device-token
ekgns33 b76ae79
:white_check_mark: test : fix command-dto params
ekgns33 9480acd
:bug: fix : add device-platform validation
ekgns33 6b20ce0
:white_check_mark: test : update command params
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
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
5 changes: 4 additions & 1 deletion
5
src/main/java/org/runimo/runimo/auth/service/dto/UserSignupCommand.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,14 +1,17 @@ | ||
| package org.runimo.runimo.auth.service.dto; | ||
|
|
||
|
|
||
| import org.runimo.runimo.user.domain.DevicePlatform; | ||
| import org.runimo.runimo.user.domain.Gender; | ||
| import org.springframework.web.multipart.MultipartFile; | ||
|
|
||
| public record UserSignupCommand( | ||
| String registerToken, | ||
| String nickname, | ||
| MultipartFile profileImage, | ||
| Gender gender | ||
| Gender gender, | ||
| String deviceToken, | ||
| DevicePlatform devicePlatform | ||
| ) { | ||
|
|
||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/org/runimo/runimo/user/domain/DevicePlatform.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,11 @@ | ||
| package org.runimo.runimo.user.domain; | ||
|
|
||
| public enum DevicePlatform { | ||
| FCM, | ||
| APNS; | ||
|
|
||
|
|
||
| public static DevicePlatform fromString(String value) { | ||
| return DevicePlatform.valueOf(value.toUpperCase()); | ||
| } | ||
| } | ||
60 changes: 60 additions & 0 deletions
60
src/main/java/org/runimo/runimo/user/domain/UserDeviceToken.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,60 @@ | ||
| package org.runimo.runimo.user.domain; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import jakarta.persistence.Table; | ||
| import java.time.LocalDateTime; | ||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.runimo.runimo.common.CreateUpdateAuditEntity; | ||
|
|
||
| @Table(name = "user_token") | ||
| @Entity | ||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class UserDeviceToken extends CreateUpdateAuditEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @JoinColumn(name = "user_id", nullable = false) | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| private User user; | ||
|
|
||
| @Column(name = "device_token", nullable = false) | ||
| private String deviceToken; | ||
|
|
||
| @Column(name = "platform", nullable = false) | ||
| private DevicePlatform platform; | ||
|
|
||
| @Column(name = "notification_allowed", nullable = false) | ||
| private Boolean notificationAllowed; | ||
|
|
||
| @Column(name = "last_used_at") | ||
| private LocalDateTime lastUsedAt; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거는 언제 필요한 정보일까요? 기록용일까요
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 최근 알림 지표로 삼을 것 같아서 추가했어요! 알림 대상 테이블은 빠르게 수가 증가할 것 같아서 디바이스토큰에 넣었습니다. |
||
|
|
||
| @Column(name = "deleted_at") | ||
| private LocalDateTime deletedAt; | ||
|
|
||
| public static UserDeviceToken from(String deviceToken, DevicePlatform platform, | ||
| Boolean notificationAllowed) { | ||
| return UserDeviceToken.builder() | ||
| .deviceToken(deviceToken) | ||
| .notificationAllowed(notificationAllowed) | ||
| .platform(platform) | ||
| .build(); | ||
| } | ||
|
|
||
| } | ||
10 changes: 10 additions & 0 deletions
10
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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package org.runimo.runimo.user.repository; | ||
|
|
||
| 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> { | ||
|
|
||
| } |
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
19 changes: 19 additions & 0 deletions
19
src/main/java/org/runimo/runimo/user/service/dto/command/DeviceTokenDto.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,19 @@ | ||
| package org.runimo.runimo.user.service.dto.command; | ||
|
|
||
| import org.runimo.runimo.user.domain.DevicePlatform; | ||
|
|
||
| public record DeviceTokenDto(String token, DevicePlatform platform) { | ||
|
|
||
| public static final DeviceTokenDto EMPTY = new DeviceTokenDto("", null); | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| public static DeviceTokenDto of(String deviceToken, DevicePlatform devicePlatform) { | ||
| if (deviceToken == null || deviceToken.isEmpty()) { | ||
| return EMPTY; | ||
| } | ||
| return new DeviceTokenDto(deviceToken, devicePlatform); | ||
| } | ||
ekgns33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public boolean isEmpty() { | ||
| return this == EMPTY; | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add null safety to the fromString method.
The method will throw a
NullPointerExceptionif a null string is passed, since it callstoUpperCase()on the input without null checking.public static DevicePlatform fromString(String value) { + if (value == null) { + throw new IllegalArgumentException("Device platform value cannot be null"); + } return DevicePlatform.valueOf(value.toUpperCase()); }📝 Committable suggestion
🤖 Prompt for AI Agents