-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Redis 모듈 재 추가 후 RedisRepository 생성
API 모듈에서 직접 RedisTemplate을 사용할 필요 없이 db-redis 모듈의 커스텀 RedisRepository 객체를 사용하도록 만들어서 redisTemplate 직접 의존 제거
- Loading branch information
jemin
committed
Jan 27, 2024
1 parent
68a1be9
commit 4fd8895
Showing
22 changed files
with
196 additions
and
149 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
21 changes: 21 additions & 0 deletions
21
core/core-api/src/main/java/cmc/mellyserver/auth/service/NotificationTokenDao.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,21 @@ | ||
package cmc.mellyserver.auth.service; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
|
||
import cmc.mellyserver.dbredis.repository.RedisRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class NotificationTokenDao { | ||
|
||
private final RedisRepository repository; | ||
|
||
public void save(String key, String fcmToken) { | ||
repository.save(key, fcmToken); | ||
} | ||
|
||
public void remove(String key) { | ||
repository.delete(key); | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
core/core-api/src/main/java/cmc/mellyserver/auth/token/AuthTokenDao.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,42 @@ | ||
package cmc.mellyserver.auth.token; | ||
|
||
import static cmc.mellyserver.auth.token.TokenConstants.*; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import cmc.mellyserver.dbredis.repository.RedisRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class AuthTokenDao { | ||
|
||
private final RedisRepository repository; | ||
|
||
public void saveRefreshToken(RefreshToken refreshToken, Long refreshTokenExpiredTime) { | ||
repository.save(REFRESH_TOKEN_PREFIX + refreshToken.userId(), refreshToken.refreshToken(), | ||
refreshTokenExpiredTime); | ||
} | ||
|
||
public void makeAccessTokenDisabled(String accessToken, long lastExpiredTime) { | ||
repository.save(accessToken, ACCESS_TOKEN_BLACKLIST, lastExpiredTime); | ||
} | ||
|
||
public Optional<RefreshToken> findRefreshToken(Long userId) { | ||
|
||
String refreshToken = repository.get(REFRESH_TOKEN_PREFIX + userId); | ||
|
||
if (Objects.isNull(refreshToken)) { | ||
return Optional.empty(); | ||
} | ||
|
||
return Optional.of(new RefreshToken(refreshToken, userId)); | ||
} | ||
|
||
public void removeRefreshToken(Long userId) { | ||
repository.delete(REFRESH_TOKEN_PREFIX + userId); | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
core/core-api/src/main/java/cmc/mellyserver/auth/token/AuthTokenRepository.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
core/core-api/src/main/java/cmc/mellyserver/auth/token/FcmTokenRepository.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
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
Oops, something went wrong.