Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Jan 25, 2024
1 parent 8e92d31 commit 938045f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import com.example.daemawiki.domain.mail.dto.AuthCodeVerifyResponse;
import com.example.daemawiki.domain.mail.service.MailSend;
import com.example.daemawiki.domain.mail.service.MailVerify;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

@RestController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import reactor.core.scheduler.Schedulers;

import java.io.UnsupportedEncodingException;
import java.util.Objects;
import java.util.Random;

@Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ private AuthCodeVerifyResponse getResponse(Boolean bool) {
.build();
}

private Mono<AuthMail> save(String mail) {
private Mono<Void> save(String mail) {
return mailRepository.save(AuthMail.builder()
.mail(mail)
.build());
}

private Mono<AuthCode> getAuthCode(String mail, String authCode) {
return codeRepository.findByMailAndCode(mail, authCode);
return codeRepository.findByMail(mail)
.filter(a -> a.getCode().equals(authCode));
}

}
14 changes: 14 additions & 0 deletions src/main/java/com/example/daemawiki/domain/mail/type/RedisKey.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.daemawiki.domain.mail.type;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum RedisKey {

AUTH_MAIL("MAIL_"),
AUTH_CODE("CODE_");

private final String key;
}
30 changes: 30 additions & 0 deletions src/main/java/com/example/daemawiki/global/config/RedisConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.example.daemawiki.global.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
import org.springframework.data.redis.core.ReactiveRedisOperations;
import org.springframework.data.redis.core.ReactiveRedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration
public class RedisConfig {

@Primary
@Bean
ReactiveRedisOperations<String, String> redisOperations(ReactiveRedisConnectionFactory factory) {
RedisSerializer<String> serializer = new StringRedisSerializer();
RedisSerializationContext<String, String> serializationContext = RedisSerializationContext
.<String, String>newSerializationContext()
.key(serializer)
.value(serializer)
.hashKey(serializer)
.hashValue(serializer)
.build();

return new ReactiveRedisTemplate<>(factory, serializationContext);
}
}

0 comments on commit 938045f

Please sign in to comment.