From 1ee37dd98714484eaf320a4b4ca94d857728b234 Mon Sep 17 00:00:00 2001 From: BlueBerrySoda Date: Sun, 18 Aug 2024 12:31:14 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20#118-=ED=9D=A1=EC=97=B0=20=EA=B5=AC?= =?UTF-8?q?=EC=97=AD=20=EB=B0=8F=20=EC=82=AC=EC=A7=84=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=20=EC=BA=90=EC=8B=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/damyo/alpha/AlphaApplication.java | 2 ++ .../api/picture/service/PictureService.java | 2 ++ .../service/SmokingAreaService.java | 2 ++ .../alpha/global/config/RedisCacheConfig.java | 28 +++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 src/main/java/com/damyo/alpha/global/config/RedisCacheConfig.java diff --git a/src/main/java/com/damyo/alpha/AlphaApplication.java b/src/main/java/com/damyo/alpha/AlphaApplication.java index 4014f0a..883f8a2 100644 --- a/src/main/java/com/damyo/alpha/AlphaApplication.java +++ b/src/main/java/com/damyo/alpha/AlphaApplication.java @@ -3,9 +3,11 @@ import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cache.annotation.EnableCaching; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.scheduling.annotation.EnableScheduling; +@EnableCaching @EnableJpaAuditing @EnableScheduling @EnableBatchProcessing diff --git a/src/main/java/com/damyo/alpha/api/picture/service/PictureService.java b/src/main/java/com/damyo/alpha/api/picture/service/PictureService.java index 20c653a..b90ede5 100644 --- a/src/main/java/com/damyo/alpha/api/picture/service/PictureService.java +++ b/src/main/java/com/damyo/alpha/api/picture/service/PictureService.java @@ -14,6 +14,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.redis.core.HashOperations; @@ -43,6 +44,7 @@ public class PictureService { @Autowired private RedisTemplate countTemplate; + @Cacheable(value="pictureCache", key="#id", cacheManager="contentCacheManager") public PictureResponse getPicture(Long id) { Picture picture = pictureRepository.findPictureById(id) .orElseThrow(() -> { diff --git a/src/main/java/com/damyo/alpha/api/smokingarea/service/SmokingAreaService.java b/src/main/java/com/damyo/alpha/api/smokingarea/service/SmokingAreaService.java index da7abf0..4c63803 100644 --- a/src/main/java/com/damyo/alpha/api/smokingarea/service/SmokingAreaService.java +++ b/src/main/java/com/damyo/alpha/api/smokingarea/service/SmokingAreaService.java @@ -6,6 +6,7 @@ import com.damyo.alpha.api.smokingarea.exception.AreaException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.cache.annotation.Cacheable; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.SetOperations; import org.springframework.scheduling.annotation.Scheduled; @@ -37,6 +38,7 @@ public List findAreaAll(){ return areaResponses; } + @Cacheable(value="areaCache", key="#smokingAreaId", cacheManager="contentCacheManager") public SmokingArea findAreaById(String smokingAreaId) { SmokingArea area = smokingAreaRepository.findSmokingAreaById(smokingAreaId) .orElseThrow(() -> { diff --git a/src/main/java/com/damyo/alpha/global/config/RedisCacheConfig.java b/src/main/java/com/damyo/alpha/global/config/RedisCacheConfig.java new file mode 100644 index 0000000..0854d4b --- /dev/null +++ b/src/main/java/com/damyo/alpha/global/config/RedisCacheConfig.java @@ -0,0 +1,28 @@ +package com.damyo.alpha.global.config; + +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.EnableCaching; +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.serializer.GenericJackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.RedisSerializationContext; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +import java.time.Duration; + +@Configuration +@EnableCaching +public class RedisCacheConfig { + @Bean + public CacheManager contentCacheManager(RedisConnectionFactory rcf) { + RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig() + .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) + .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new GenericJackson2JsonRedisSerializer())) + .entryTtl(Duration.ofMinutes(30L)); + + return RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(rcf).cacheDefaults(redisCacheConfiguration).build(); + } +} From ab7b7287d251b23b4ff87957104084b5deb84181 Mon Sep 17 00:00:00 2001 From: BlueBerrySoda Date: Sun, 18 Aug 2024 13:13:46 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20#118-=ED=9D=A1=EC=97=B0=20=EA=B5=AC?= =?UTF-8?q?=EC=97=AD=20Redis=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/damyo/alpha/api/info/service/InfoService.java | 6 ++++++ .../alpha/api/smokingarea/domain/SmokingAreaRepository.java | 5 +++++ .../alpha/api/smokingdata/service/SmokingDataService.java | 2 ++ .../java/com/damyo/alpha/api/star/service/StarService.java | 2 ++ 4 files changed, 15 insertions(+) diff --git a/src/main/java/com/damyo/alpha/api/info/service/InfoService.java b/src/main/java/com/damyo/alpha/api/info/service/InfoService.java index fd7c21c..54e3bf8 100644 --- a/src/main/java/com/damyo/alpha/api/info/service/InfoService.java +++ b/src/main/java/com/damyo/alpha/api/info/service/InfoService.java @@ -13,6 +13,8 @@ import com.damyo.alpha.api.user.service.UserService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.cache.annotation.CachePut; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import java.util.List; @@ -30,6 +32,7 @@ public class InfoService { private static final int POST_INFO_CONTRIBUTION_INCREMENT = 5; + @CachePut(value="areaCache", key="#updateInfoRequest.smokingAreaId()", cacheManager="contentCacheManager") public void updateInfo(UpdateInfoRequest updateInfoRequest, UserDetailsImpl details) { SmokingArea sa = smokingAreaRepository.findSmokingAreaById(updateInfoRequest.smokingAreaId()) .orElseThrow(() -> { @@ -38,6 +41,9 @@ public void updateInfo(UpdateInfoRequest updateInfoRequest, UserDetailsImpl deta }); User user = details.getUser(); infoRepository.save(updateInfoRequest.toEntity(sa, user)); + int size = infoRepository.findInfosBySmokingAreaId(updateInfoRequest.smokingAreaId()).size(); + Float score = (sa.getScore() * size + updateInfoRequest.score()) / (size + 1); + smokingAreaRepository.updateSmokingAreaScoreById(score, sa.getId()); userService.updateContribution(user.getId(), POST_INFO_CONTRIBUTION_INCREMENT); log.info("[Info]: info update complete"); } diff --git a/src/main/java/com/damyo/alpha/api/smokingarea/domain/SmokingAreaRepository.java b/src/main/java/com/damyo/alpha/api/smokingarea/domain/SmokingAreaRepository.java index 2377b90..1012a22 100644 --- a/src/main/java/com/damyo/alpha/api/smokingarea/domain/SmokingAreaRepository.java +++ b/src/main/java/com/damyo/alpha/api/smokingarea/domain/SmokingAreaRepository.java @@ -53,6 +53,11 @@ public interface SmokingAreaRepository extends JpaRepository Date: Sun, 18 Aug 2024 13:17:33 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20#118-=ED=9D=A1=EC=97=B0=20=EA=B5=AC?= =?UTF-8?q?=EC=97=AD=20Redis=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/damyo/alpha/api/info/service/InfoService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/damyo/alpha/api/info/service/InfoService.java b/src/main/java/com/damyo/alpha/api/info/service/InfoService.java index 54e3bf8..406d920 100644 --- a/src/main/java/com/damyo/alpha/api/info/service/InfoService.java +++ b/src/main/java/com/damyo/alpha/api/info/service/InfoService.java @@ -13,6 +13,7 @@ import com.damyo.alpha.api.user.service.UserService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; @@ -32,7 +33,7 @@ public class InfoService { private static final int POST_INFO_CONTRIBUTION_INCREMENT = 5; - @CachePut(value="areaCache", key="#updateInfoRequest.smokingAreaId()", cacheManager="contentCacheManager") + @CacheEvict(value="areaCache", key="#updateInfoRequest.smokingAreaId()", cacheManager="contentCacheManager") public void updateInfo(UpdateInfoRequest updateInfoRequest, UserDetailsImpl details) { SmokingArea sa = smokingAreaRepository.findSmokingAreaById(updateInfoRequest.smokingAreaId()) .orElseThrow(() -> { From bdd8bb6523df40620622e50f64ed7c711f491c02 Mon Sep 17 00:00:00 2001 From: BlueBerrySoda Date: Mon, 19 Aug 2024 20:09:11 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20#118-=EC=82=AC=EC=A7=84=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=9C=A0=EC=A0=80/=ED=9D=A1=EC=97=B0=EA=B5=AC?= =?UTF-8?q?=EC=97=AD=EB=B3=84=20=EC=BA=90=EC=8B=B1=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 ++ .../alpha/api/info/service/InfoService.java | 2 +- .../controller/dto/PictureResponse.java | 6 ++++++ .../api/picture/service/PictureService.java | 2 ++ .../controller/SmokingAreaController.java | 11 ++++------- .../dto/SmokingAreaDetailResponse.java | 7 +++++++ .../service/SmokingAreaService.java | 18 ++++++++++++++---- .../service/SmokingDataService.java | 1 - .../alpha/api/star/service/StarService.java | 1 - 9 files changed, 36 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 4ad16b9..cbabfc2 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,9 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-validation' + // redis implementation 'org.springframework.boot:spring-boot-starter-data-redis' + implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' // jwt implementation 'io.jsonwebtoken:jjwt-api:0.11.5' diff --git a/src/main/java/com/damyo/alpha/api/info/service/InfoService.java b/src/main/java/com/damyo/alpha/api/info/service/InfoService.java index 406d920..5e62156 100644 --- a/src/main/java/com/damyo/alpha/api/info/service/InfoService.java +++ b/src/main/java/com/damyo/alpha/api/info/service/InfoService.java @@ -33,7 +33,7 @@ public class InfoService { private static final int POST_INFO_CONTRIBUTION_INCREMENT = 5; - @CacheEvict(value="areaCache", key="#updateInfoRequest.smokingAreaId()", cacheManager="contentCacheManager") + @CacheEvict(value={"areaDetailsCache", "areaSummaryCache"}, key="#updateInfoRequest.smokingAreaId()", cacheManager="contentCacheManager") public void updateInfo(UpdateInfoRequest updateInfoRequest, UserDetailsImpl details) { SmokingArea sa = smokingAreaRepository.findSmokingAreaById(updateInfoRequest.smokingAreaId()) .orElseThrow(() -> { diff --git a/src/main/java/com/damyo/alpha/api/picture/controller/dto/PictureResponse.java b/src/main/java/com/damyo/alpha/api/picture/controller/dto/PictureResponse.java index 12ecd14..ded28f0 100644 --- a/src/main/java/com/damyo/alpha/api/picture/controller/dto/PictureResponse.java +++ b/src/main/java/com/damyo/alpha/api/picture/controller/dto/PictureResponse.java @@ -1,11 +1,17 @@ package com.damyo.alpha.api.picture.controller.dto; import com.damyo.alpha.api.picture.domain.Picture; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import java.time.LocalDateTime; public record PictureResponse ( Long id, String pictureUrl, + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) LocalDateTime createdAt, Long likes ) { diff --git a/src/main/java/com/damyo/alpha/api/picture/service/PictureService.java b/src/main/java/com/damyo/alpha/api/picture/service/PictureService.java index b90ede5..dcdfa55 100644 --- a/src/main/java/com/damyo/alpha/api/picture/service/PictureService.java +++ b/src/main/java/com/damyo/alpha/api/picture/service/PictureService.java @@ -55,12 +55,14 @@ public PictureResponse getPicture(Long id) { return new PictureResponse(picture); } + @Cacheable(value="pictureUserCache", key="#id", cacheManager="contentCacheManager") public List getPicturesByUser(UUID id) { List pictures = pictureRepository.findPicturesByUser_id(id); log.info("[Picture]: load pictures by user | {}", id); return getPictureListResponse(pictures); } + @Cacheable(value="pictureAreaCache", key="#id", cacheManager="contentCacheManager") public List getPicturesBySmokingArea(String id, Long count) { List pictures = pictureRepository.findPicturesBySmokingArea_Id(id, count); log.info("[Picture]: load pictures by area | {}", id); diff --git a/src/main/java/com/damyo/alpha/api/smokingarea/controller/SmokingAreaController.java b/src/main/java/com/damyo/alpha/api/smokingarea/controller/SmokingAreaController.java index fdec4a4..c41581a 100644 --- a/src/main/java/com/damyo/alpha/api/smokingarea/controller/SmokingAreaController.java +++ b/src/main/java/com/damyo/alpha/api/smokingarea/controller/SmokingAreaController.java @@ -46,7 +46,6 @@ public class SmokingAreaController { private final SmokingAreaService smokingAreaService; private final PictureService pictureService; private final UserService userService; - private final InfoService infoService; private final S3ImageService s3ImageService; private final RedisTemplate redisTemplate; @@ -108,13 +107,11 @@ public ResponseEntity getSmokingAreaDetailsById( @Parameter(description = "흡연구역 ID", in = ParameterIn.PATH) @PathVariable String smokingAreaId){ log.info("[Area]: /details/{}", smokingAreaId); - SmokingAreaDetailResponse area = smokingAreaService.findAreaById(smokingAreaId).toDTO(); - InfoResponse info = infoService.getInfo(smokingAreaId); - Float avgScore = Math.round((info.score() + area.score()) / (info.size()+1) * 10) / 10.0F; + SmokingAreaDetailResponse area = smokingAreaService.findAreaDTOById(smokingAreaId); List picList = pictureService.getPicturesBySmokingArea(smokingAreaId, 10L); SmokingAreaAllResponse response = new SmokingAreaAllResponse(area.areaId(), area.name(), area.latitude(), area.longitude(), area.address(), - area.createdAt(), area.description(), avgScore, area.status(), area.opened(), area.closed(), + area.createdAt(), area.description(), area.score(), area.status(), area.opened(), area.closed(), area.indoor(), area.outdoor(), picList); return ResponseEntity.ok(response); @@ -129,9 +126,9 @@ public ResponseEntity getSmokingAreaSummaryById( @Parameter(description = "흡연구역 ID", in = ParameterIn.PATH) @PathVariable String smokingAreaId){ log.info("[Area]: /summary/{}", smokingAreaId); - SmokingArea areaResponse = smokingAreaService.findAreaById(smokingAreaId); + SmokingAreaSummaryResponse response = smokingAreaService.findAreaSUMById(smokingAreaId); - return ResponseEntity.ok(areaResponse.toSUM()); + return ResponseEntity.ok(response); } // 특정날짜이후 추가된 구역찾기 diff --git a/src/main/java/com/damyo/alpha/api/smokingarea/controller/dto/SmokingAreaDetailResponse.java b/src/main/java/com/damyo/alpha/api/smokingarea/controller/dto/SmokingAreaDetailResponse.java index bc3d88d..af048ac 100644 --- a/src/main/java/com/damyo/alpha/api/smokingarea/controller/dto/SmokingAreaDetailResponse.java +++ b/src/main/java/com/damyo/alpha/api/smokingarea/controller/dto/SmokingAreaDetailResponse.java @@ -1,5 +1,10 @@ package com.damyo.alpha.api.smokingarea.controller.dto; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; + import java.math.BigDecimal; import java.time.LocalDateTime; @@ -9,6 +14,8 @@ public record SmokingAreaDetailResponse( BigDecimal latitude, BigDecimal longitude, String address, + @JsonSerialize(using = LocalDateTimeSerializer.class) + @JsonDeserialize(using = LocalDateTimeDeserializer.class) LocalDateTime createdAt, Boolean status, String description, diff --git a/src/main/java/com/damyo/alpha/api/smokingarea/service/SmokingAreaService.java b/src/main/java/com/damyo/alpha/api/smokingarea/service/SmokingAreaService.java index 4c63803..61ae290 100644 --- a/src/main/java/com/damyo/alpha/api/smokingarea/service/SmokingAreaService.java +++ b/src/main/java/com/damyo/alpha/api/smokingarea/service/SmokingAreaService.java @@ -38,14 +38,24 @@ public List findAreaAll(){ return areaResponses; } - @Cacheable(value="areaCache", key="#smokingAreaId", cacheManager="contentCacheManager") - public SmokingArea findAreaById(String smokingAreaId) { + @Cacheable(value="areaDetailsCache", key="#smokingAreaId", cacheManager="contentCacheManager") + public SmokingAreaDetailResponse findAreaDTOById(String smokingAreaId) { SmokingArea area = smokingAreaRepository.findSmokingAreaById(smokingAreaId) .orElseThrow(() -> { - log.error("[Area]: area not found by id | {}", smokingAreaId); + log.error("[Area]: area detail not found by id | {}", smokingAreaId); return new AreaException(NOT_FOUND_ID); }); - return area; + return area.toDTO(); + } + + @Cacheable(value="areaSummaryCache", key="#smokingAreaId", cacheManager="contentCacheManager") + public SmokingAreaSummaryResponse findAreaSUMById(String smokingAreaId) { + SmokingArea area = smokingAreaRepository.findSmokingAreaById(smokingAreaId) + .orElseThrow(() -> { + log.error("[Area]: area summary not found by id | {}", smokingAreaId); + return new AreaException(NOT_FOUND_ID); + }); + return area.toSUM(); } public List findAreaByCreatedAt(LocalDateTime createdAt) { diff --git a/src/main/java/com/damyo/alpha/api/smokingdata/service/SmokingDataService.java b/src/main/java/com/damyo/alpha/api/smokingdata/service/SmokingDataService.java index 783d627..0cc065d 100644 --- a/src/main/java/com/damyo/alpha/api/smokingdata/service/SmokingDataService.java +++ b/src/main/java/com/damyo/alpha/api/smokingdata/service/SmokingDataService.java @@ -24,7 +24,6 @@ public class SmokingDataService { private final SmokingAreaRepository smokingAreaRepository; private final UserRepository userRepository; - @Cacheable(value="areaCache", key="#areaId", cacheManager="contentCacheManager") public void addSmokingData(UUID userId, String areaId) { SmokingArea area = smokingAreaRepository.findSmokingAreaById(areaId).get(); User user = userRepository.findUserById(userId).get(); diff --git a/src/main/java/com/damyo/alpha/api/star/service/StarService.java b/src/main/java/com/damyo/alpha/api/star/service/StarService.java index 684bad1..dc189e1 100644 --- a/src/main/java/com/damyo/alpha/api/star/service/StarService.java +++ b/src/main/java/com/damyo/alpha/api/star/service/StarService.java @@ -31,7 +31,6 @@ public class StarService { private final StarRepository starRepository; private final SmokingAreaRepository smokingAreaRepository; - @Cacheable(value="areaCache", key="#request.saId()", cacheManager="contentCacheManager") public void addStar(AddStarRequest request, UserDetailsImpl details) { // 예외 처리 해야함 SmokingArea smokingArea = smokingAreaRepository.findSmokingAreaById(request.saId()).get(); From ed65ea18b142ab48d4c13facb7a39db76dd910f1 Mon Sep 17 00:00:00 2001 From: BlueBerrySoda Date: Mon, 19 Aug 2024 20:11:34 +0900 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20#120-=EB=A6=AC=EB=B7=B0=20=ED=8F=89?= =?UTF-8?q?=EC=A0=90=EC=9D=B4=20=EB=B0=98=EC=98=81=EB=90=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alpha/api/smokingarea/controller/SmokingAreaController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/damyo/alpha/api/smokingarea/controller/SmokingAreaController.java b/src/main/java/com/damyo/alpha/api/smokingarea/controller/SmokingAreaController.java index c41581a..bf4a140 100644 --- a/src/main/java/com/damyo/alpha/api/smokingarea/controller/SmokingAreaController.java +++ b/src/main/java/com/damyo/alpha/api/smokingarea/controller/SmokingAreaController.java @@ -107,6 +107,7 @@ public ResponseEntity getSmokingAreaDetailsById( @Parameter(description = "흡연구역 ID", in = ParameterIn.PATH) @PathVariable String smokingAreaId){ log.info("[Area]: /details/{}", smokingAreaId); + SmokingAreaDetailResponse area = smokingAreaService.findAreaDTOById(smokingAreaId); List picList = pictureService.getPicturesBySmokingArea(smokingAreaId, 10L); From a84f67e267761c0e26446a9d23f4e223c904e29d Mon Sep 17 00:00:00 2001 From: BlueBerrySoda Date: Tue, 20 Aug 2024 15:27:13 +0900 Subject: [PATCH 6/6] =?UTF-8?q?fix:=20#120-=EB=A6=AC=EB=B7=B0=20=EC=A0=90?= =?UTF-8?q?=EC=88=98=20=EA=B3=84=EC=82=B0=20=EC=98=A4=EB=A5=98=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/damyo/alpha/api/info/service/InfoService.java | 1 + .../alpha/api/smokingarea/domain/SmokingAreaRepository.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/damyo/alpha/api/info/service/InfoService.java b/src/main/java/com/damyo/alpha/api/info/service/InfoService.java index 5e62156..0856f55 100644 --- a/src/main/java/com/damyo/alpha/api/info/service/InfoService.java +++ b/src/main/java/com/damyo/alpha/api/info/service/InfoService.java @@ -43,6 +43,7 @@ public void updateInfo(UpdateInfoRequest updateInfoRequest, UserDetailsImpl deta User user = details.getUser(); infoRepository.save(updateInfoRequest.toEntity(sa, user)); int size = infoRepository.findInfosBySmokingAreaId(updateInfoRequest.smokingAreaId()).size(); + log.info("[test]: {}", size); Float score = (sa.getScore() * size + updateInfoRequest.score()) / (size + 1); smokingAreaRepository.updateSmokingAreaScoreById(score, sa.getId()); userService.updateContribution(user.getId(), POST_INFO_CONTRIBUTION_INCREMENT); diff --git a/src/main/java/com/damyo/alpha/api/smokingarea/domain/SmokingAreaRepository.java b/src/main/java/com/damyo/alpha/api/smokingarea/domain/SmokingAreaRepository.java index 1012a22..ed20372 100644 --- a/src/main/java/com/damyo/alpha/api/smokingarea/domain/SmokingAreaRepository.java +++ b/src/main/java/com/damyo/alpha/api/smokingarea/domain/SmokingAreaRepository.java @@ -53,6 +53,7 @@ public interface SmokingAreaRepository extends JpaRepository