From d7b2ac438a673708773005b17bbe87f6e1520e71 Mon Sep 17 00:00:00 2001 From: thguss Date: Sun, 9 Jun 2024 16:58:37 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[DELETE]=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/smeem/api/member/service/MemberService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/smeem-api/src/main/java/com/smeem/api/member/service/MemberService.java b/smeem-api/src/main/java/com/smeem/api/member/service/MemberService.java index 51b528d2..5899ee1c 100644 --- a/smeem-api/src/main/java/com/smeem/api/member/service/MemberService.java +++ b/smeem-api/src/main/java/com/smeem/api/member/service/MemberService.java @@ -48,7 +48,6 @@ public class MemberService { private final PlanFinder planFinder; private final VisitSaver visitSaver; private final VisitFinder visitFinder; - private final VisitCounter visitorCounter; private final TrainingTimeService trainingTimeService; private final GoalService goalService; From 27d9803dbcb59fa56b9f1e4d2164c7f31067f3ee Mon Sep 17 00:00:00 2001 From: thguss Date: Sun, 9 Jun 2024 17:00:51 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[REFACTOR]=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/smeem/external/{ => firebase}/config/FcmConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename smeem-external/src/main/java/com/smeem/external/{ => firebase}/config/FcmConfig.java (97%) diff --git a/smeem-external/src/main/java/com/smeem/external/config/FcmConfig.java b/smeem-external/src/main/java/com/smeem/external/firebase/config/FcmConfig.java similarity index 97% rename from smeem-external/src/main/java/com/smeem/external/config/FcmConfig.java rename to smeem-external/src/main/java/com/smeem/external/firebase/config/FcmConfig.java index 805e5c82..5d344ea0 100644 --- a/smeem-external/src/main/java/com/smeem/external/config/FcmConfig.java +++ b/smeem-external/src/main/java/com/smeem/external/firebase/config/FcmConfig.java @@ -1,4 +1,4 @@ -package com.smeem.external.config; +package com.smeem.external.firebase.config; import com.google.auth.oauth2.GoogleCredentials; import com.google.firebase.FirebaseApp; From e6ef5be02422893bd5767acd771f6d257ae9eda8 Mon Sep 17 00:00:00 2001 From: thguss Date: Sun, 9 Jun 2024 17:51:49 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[INIT]=20Redis=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../external/redis/config/RedisConfig.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 smeem-external/src/main/java/com/smeem/external/redis/config/RedisConfig.java diff --git a/smeem-external/src/main/java/com/smeem/external/redis/config/RedisConfig.java b/smeem-external/src/main/java/com/smeem/external/redis/config/RedisConfig.java new file mode 100644 index 00000000..52b6677e --- /dev/null +++ b/smeem-external/src/main/java/com/smeem/external/redis/config/RedisConfig.java @@ -0,0 +1,76 @@ +package com.smeem.external.redis.config; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.json.JsonMapper; +import lombok.val; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cache.CacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.cache.RedisCacheConfiguration; +import org.springframework.data.redis.cache.RedisCacheManager; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.RedisSerializationContext.SerializationPair; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +@Configuration +public class RedisConfig { + + @Value("${redis.host}") + private String redisHost; + + @Value("${redis.port}") + private int redisPort; + + @Bean + public ObjectMapper objectMapper() { + return JsonMapper.builder() + .configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true) + .configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, false) + .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) + .configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true) + .findAndAddModules() + .build(); + } + + @Bean + public RedisConnectionFactory redisConnectionFactory() { + return new LettuceConnectionFactory(redisHost, redisPort); + } + + @Bean + public RedisTemplate redisTemplate() { + val redisTemplate = new RedisTemplate(); + redisTemplate.setConnectionFactory(redisConnectionFactory()); + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer(objectMapper())); + return redisTemplate; + } + + @Bean + public GenericJackson2JsonRedisSerializer redisSerializer() { + return new GenericJackson2JsonRedisSerializer(objectMapper()); + } + + @Bean + public RedisCacheConfiguration redisCacheConfiguration() { + return RedisCacheConfiguration.defaultCacheConfig() + .serializeKeysWith(SerializationPair.fromSerializer(new StringRedisSerializer())) + .serializeValuesWith(SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer())); +// .entryTtl(Duration.ofMinutes(1)); + } + + @Bean + public CacheManager cacheManager() { + return RedisCacheManager + .builder(redisConnectionFactory()) + .cacheDefaults(redisCacheConfiguration()) + .build(); + } +} From 483e80b479cf8036354149dabf946861ce4c9645 Mon Sep 17 00:00:00 2001 From: thguss Date: Sun, 9 Jun 2024 17:55:07 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[INIT]=20Redis=20=EC=B4=88=EA=B8=B0=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smeem-external/build.gradle | 5 ++++- smeem-external/src/main/resources/application-local.yml | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 smeem-external/src/main/resources/application-local.yml diff --git a/smeem-external/build.gradle b/smeem-external/build.gradle index be749a0a..16d739e5 100644 --- a/smeem-external/build.gradle +++ b/smeem-external/build.gradle @@ -18,4 +18,7 @@ dependencies { implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.5' implementation group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.5' implementation group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.5' -} \ No newline at end of file + + // redis + implementation 'org.springframework.boot:spring-boot-starter-data-redis' +} diff --git a/smeem-external/src/main/resources/application-local.yml b/smeem-external/src/main/resources/application-local.yml new file mode 100644 index 00000000..44f2bd9d --- /dev/null +++ b/smeem-external/src/main/resources/application-local.yml @@ -0,0 +1,8 @@ +spring: + config: + activate: + on-profile: local + +redis: + host: localhost + port: 6379