-
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.
Implement device service to manage device token and fcm token refresh…
… tokens simultaneously (#145)
- Loading branch information
Showing
23 changed files
with
270 additions
and
420 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
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
23 changes: 23 additions & 0 deletions
23
src/main/java/org/swmaestro/repl/gifthub/auth/dto/UserDeviceDto.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 org.swmaestro.repl.gifthub.auth.dto; | ||
|
||
import com.fasterxml.jackson.databind.PropertyNamingStrategy; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | ||
public class UserDeviceDto { | ||
private String deviceToken; | ||
private String fcmToken; | ||
|
||
@Builder | ||
public UserDeviceDto(String deviceToken, String fcmToken) { | ||
this.deviceToken = deviceToken; | ||
this.fcmToken = fcmToken; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/org/swmaestro/repl/gifthub/auth/entity/Device.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,52 @@ | ||
package org.swmaestro.repl.gifthub.auth.entity; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class Device { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private Long userId; | ||
|
||
@Column(length = 255, nullable = false) | ||
private String refreshToken; | ||
|
||
@Column(length = 200, nullable = false) | ||
private String deviceToken; | ||
|
||
@Column(length = 200) | ||
private String fcmToken; | ||
|
||
@CreatedDate | ||
@Column(nullable = false) | ||
private LocalDateTime createdAt; | ||
|
||
@Builder | ||
public Device(Long id, Long userId, String refreshToken, String deviceToken, String fcmToken) { | ||
this.id = id; | ||
this.userId = userId; | ||
this.refreshToken = refreshToken; | ||
this.deviceToken = deviceToken; | ||
this.fcmToken = fcmToken; | ||
} | ||
} |
38 changes: 0 additions & 38 deletions
38
src/main/java/org/swmaestro/repl/gifthub/auth/entity/DeviceToken.java
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
src/main/java/org/swmaestro/repl/gifthub/auth/entity/RefreshToken.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/main/java/org/swmaestro/repl/gifthub/auth/repository/DeviceRepository.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,18 @@ | ||
package org.swmaestro.repl.gifthub.auth.repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.swmaestro.repl.gifthub.auth.entity.Device; | ||
|
||
public interface DeviceRepository extends JpaRepository<Device, Long> { | ||
|
||
Optional<Device> findByUserIdAndDeviceToken(Long userId, String deviceToken); | ||
|
||
void deleteByUserIdAndDeviceToken(Long userId, String deviceToken); | ||
|
||
Device findByRefreshToken(String refreshToken); | ||
|
||
List<Device> findAllByUserId(Long userId); | ||
} |
18 changes: 0 additions & 18 deletions
18
src/main/java/org/swmaestro/repl/gifthub/auth/repository/DeviceTokenRepository.java
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
src/main/java/org/swmaestro/repl/gifthub/auth/repository/RefreshTokenRepository.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.