diff --git a/src/main/java/com/j9/bestmoments/constants/TokenExpiration.java b/src/main/java/com/j9/bestmoments/constants/TokenExpiration.java new file mode 100644 index 0000000..eddcbcb --- /dev/null +++ b/src/main/java/com/j9/bestmoments/constants/TokenExpiration.java @@ -0,0 +1,11 @@ +package com.j9.bestmoments.constants; + +public final class TokenExpiration { + + // 10분 + public static final int ACCESS_TOKEN = 60 * 10; + + // 60분 + public static final int REFRESH_TOKEN = 60 * 60; + +} diff --git a/src/main/java/com/j9/bestmoments/domain/AccessToken.java b/src/main/java/com/j9/bestmoments/domain/AccessToken.java new file mode 100644 index 0000000..2494067 --- /dev/null +++ b/src/main/java/com/j9/bestmoments/domain/AccessToken.java @@ -0,0 +1,13 @@ +package com.j9.bestmoments.domain; + +import com.j9.bestmoments.constants.TokenExpiration; +import org.springframework.data.redis.core.RedisHash; + +@RedisHash(value = "AccessToken", timeToLive = TokenExpiration.ACCESS_TOKEN) +public class AccessToken extends Token_ { + + public AccessToken(Member member, String token) { + super(member, token); + } + +} diff --git a/src/main/java/com/j9/bestmoments/domain/RefreshToken.java b/src/main/java/com/j9/bestmoments/domain/RefreshToken.java new file mode 100644 index 0000000..015ee1f --- /dev/null +++ b/src/main/java/com/j9/bestmoments/domain/RefreshToken.java @@ -0,0 +1,13 @@ +package com.j9.bestmoments.domain; + +import com.j9.bestmoments.constants.TokenExpiration; +import org.springframework.data.redis.core.RedisHash; + +@RedisHash(value = "RefreshToken", timeToLive = TokenExpiration.REFRESH_TOKEN) +public class RefreshToken extends Token_ { + + public RefreshToken(Member member, String token) { + super(member, token); + } + +} diff --git a/src/main/java/com/j9/bestmoments/domain/Token_.java b/src/main/java/com/j9/bestmoments/domain/Token_.java new file mode 100644 index 0000000..ccdd392 --- /dev/null +++ b/src/main/java/com/j9/bestmoments/domain/Token_.java @@ -0,0 +1,23 @@ +package com.j9.bestmoments.domain; + +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.Id; +import java.util.UUID; +import lombok.Getter; +import org.springframework.data.redis.core.RedisHash; + +@Getter +@NoArgsConstructor +@RedisHash("Token") +public class Token_ { + + @Id + private String token; + private UUID memberId; + + public Token_(Member member, String token) { + this.token = token; + this.memberId = member.getId(); + } + +} diff --git a/src/main/java/com/j9/bestmoments/repository/Token_Repository.java b/src/main/java/com/j9/bestmoments/repository/Token_Repository.java new file mode 100644 index 0000000..c0131eb --- /dev/null +++ b/src/main/java/com/j9/bestmoments/repository/Token_Repository.java @@ -0,0 +1,10 @@ +package com.j9.bestmoments.repository; + +import com.j9.bestmoments.domain.Token_; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface Token_Repository extends CrudRepository { + +} diff --git a/src/main/java/com/j9/bestmoments/service/Token_Service.java b/src/main/java/com/j9/bestmoments/service/Token_Service.java new file mode 100644 index 0000000..ccbc9f2 --- /dev/null +++ b/src/main/java/com/j9/bestmoments/service/Token_Service.java @@ -0,0 +1,13 @@ +package com.j9.bestmoments.service; + +import com.j9.bestmoments.repository.Token_Repository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class Token_Service { + + private final Token_Repository tokenRepository; + +}