-
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.
- Loading branch information
1 parent
ea607e7
commit 4bf88ae
Showing
4 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/main/java/com/example/rework/config/redis/util/EmailRedisUtil.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,55 @@ | ||
package com.example.rework.config.redis.util; | ||
|
||
import com.example.rework.mail.MailPurpose; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.redis.core.ListOperations; | ||
import org.springframework.data.redis.core.StringRedisTemplate; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.time.Duration; | ||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class EmailRedisUtil { | ||
private final StringRedisTemplate stringRedisTemplate; | ||
|
||
// key를 통해 value 리턴 | ||
public List<String> getData(String key) { | ||
ListOperations<String, String> valueOperations = stringRedisTemplate.opsForList(); | ||
long size = valueOperations.size(key); // Get the size of the list | ||
return valueOperations.range(key, 0, size - 1); // Get all elements of the list | ||
} | ||
public boolean existData(String key) { | ||
return stringRedisTemplate.hasKey(key); | ||
} | ||
|
||
|
||
// 유효 시간 동안(key, value)저장 | ||
// public void setDataExpire(String key, Integer value, long duration) { | ||
// ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); | ||
// Duration expireDuration = Duration.ofSeconds(duration); | ||
// valueOperations.set(key, value.toString(), expireDuration); | ||
// } | ||
public void setListData(String key, String value, MailPurpose mailPurpose, long duration) { | ||
ListOperations<String, String> listOperations = stringRedisTemplate.opsForList(); | ||
String data = value + "|" + mailPurpose; | ||
Duration expireDuration = Duration.ofSeconds(duration); | ||
|
||
listOperations.leftPush(key, data); | ||
stringRedisTemplate.expire(key, expireDuration); | ||
} | ||
|
||
public void deleteData(String key) { | ||
stringRedisTemplate.delete(key); | ||
} | ||
|
||
public void setUpdatePasswordData(String email, long duration) { | ||
ListOperations<String, String> listOperations = stringRedisTemplate.opsForList(); | ||
String data = email; | ||
Duration expireDuration = Duration.ofSeconds(duration); | ||
|
||
listOperations.leftPush(email, data); | ||
stringRedisTemplate.expire(email, expireDuration); | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/main/java/com/example/rework/member/application/VerificationStatus.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,8 @@ | ||
package com.example.rework.member.application; | ||
|
||
public enum VerificationStatus { | ||
UNPROVIDED, | ||
EXPIRED, | ||
MATCHED, | ||
UNMATCHED | ||
} |
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,34 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<configuration> | ||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/> | ||
|
||
<springProperty name="DISCORD_WEBHOOK_URL" source="logging.discord.webhook-url"/> | ||
<appender name="DISCORD" class="com.github.napstr.logback.DiscordAppender"> | ||
<webhookUri>${discord_webhook_url3}</webhookUri> | ||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<pattern>%d{HH:mm:ss} [%thread] [%-5level] %logger{36} - %msg%n```%ex{full}```</pattern> | ||
</layout> | ||
<username>WanF-logback</username> | ||
<avatarUrl>https://cdn-icons-png.flaticon.com/512/1383/1383395.png</avatarUrl> | ||
<tts>false</tts> | ||
</appender> | ||
|
||
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern> | ||
<charset>utf8</charset> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="ASYNC_DISCORD" class="ch.qos.logback.classic.AsyncAppender"> | ||
<appender-ref ref="DISCORD" /> | ||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
<level>ERROR</level> | ||
</filter> | ||
</appender> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="ASYNC_DISCORD"/> | ||
<appender-ref ref="Console"/> | ||
</root> | ||
</configuration> |