-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
69 changed files
with
1,698 additions
and
484 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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/airjnc/common/annotation/TwoFieldMatch.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,37 @@ | ||
package com.airjnc.common.annotation; | ||
|
||
import com.airjnc.common.util.beanvalidator.TwoFieldMatchValidator; | ||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import javax.validation.Constraint; | ||
import javax.validation.Payload; | ||
|
||
// DTO 바인딩 검사에서 선택된 두 필드에 대하여 해당 두 필드의 값이 동일한 지 체크하는 애노테이션입니다. | ||
// 향후 사용할 가능성이 있을 것 같아, 현재 사용하진 않지만 지우지 않고 남겨둡니다. | ||
@Target({ElementType.TYPE}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Constraint(validatedBy = TwoFieldMatchValidator.class) | ||
public @interface TwoFieldMatch { | ||
|
||
String first(); | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
String message() default "{TwoFieldMatch}"; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
|
||
String second(); | ||
|
||
@Target({ElementType.TYPE}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@interface List { | ||
|
||
TwoFieldMatch[] value(); | ||
} | ||
} |
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,49 @@ | ||
package com.airjnc.common.config; | ||
|
||
import com.airjnc.common.properties.SessionTtlProperties; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration; | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.core.StringRedisTemplate; | ||
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; | ||
|
||
@Configuration | ||
@EnableRedisHttpSession | ||
@EnableConfigurationProperties(SessionTtlProperties.class) | ||
public class SessionConfig { | ||
|
||
@Value("${spring.redis.session.host}") | ||
private String host; | ||
|
||
@Value("${spring.redis.session.port}") | ||
private int port; | ||
|
||
@Value("${spring.redis.session.password}") | ||
private String password; | ||
|
||
@Bean | ||
public RedisConnectionFactory redisConnectionFactory() { | ||
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(); | ||
|
||
configuration.setHostName(host); | ||
configuration.setPort(port); | ||
configuration.setPassword(password); | ||
|
||
return new LettuceConnectionFactory(configuration); | ||
} | ||
|
||
@Bean | ||
public RedisTemplate<String, String> redisTemplate( | ||
RedisConnectionFactory redisConnectionFactory) { | ||
// 아직까진 value 를 객체 등등.. 문자열 그 외의 타입으로 사용할 예정이 없으므로 String으로만 serialize 진행 | ||
// 추후에, value가 복잡해진다면 `GenericJackson2JsonRedisSerializer` 을 사용할 예정 | ||
StringRedisTemplate stringRedisTemplate = new StringRedisTemplate(); | ||
stringRedisTemplate.setConnectionFactory(redisConnectionFactory); | ||
return stringRedisTemplate; | ||
} | ||
} |
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 @@ | ||
package com.airjnc.common.dao; | ||
|
||
import com.airjnc.common.exception.NotFoundException; | ||
import java.time.Duration; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class RedisDao { | ||
|
||
private final RedisTemplate<String, String> redisTemplate; | ||
|
||
public Boolean delete(String key) { | ||
return redisTemplate.delete(key); | ||
} | ||
|
||
public String get(String key) { | ||
String value = redisTemplate.opsForValue().get(key); | ||
if (value == null) { | ||
throw new NotFoundException(this.getClass().getSimpleName(), new Object[]{key}); | ||
} | ||
return value; | ||
} | ||
|
||
public void store(String key, String value, Duration timeout) { | ||
redisTemplate.opsForValue().set( | ||
key, | ||
value, | ||
timeout | ||
); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/airjnc/common/properties/NcpCredentialProperties.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,17 @@ | ||
package com.airjnc.common.properties; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.ConstructorBinding; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
@ConstructorBinding | ||
@ConfigurationProperties("cloud.naver.credential") | ||
public class NcpCredentialProperties { | ||
|
||
private final String accessKey; | ||
|
||
private final String secretKey; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/airjnc/common/properties/SessionTtlProperties.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,16 @@ | ||
package com.airjnc.common.properties; | ||
|
||
import java.time.Duration; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.ConstructorBinding; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
@ConstructorBinding | ||
@ConfigurationProperties(prefix = "spring.redis.session.ttl") | ||
public class SessionTtlProperties { | ||
|
||
private final Duration resetPasswordCode; | ||
} |
Oops, something went wrong.