From 45d11688366cfba3809124133d6e787ea8c7f5da Mon Sep 17 00:00:00 2001 From: jjongwa Date: Mon, 20 Nov 2023 22:49:44 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/hanglog/community/service/CommunityService.java | 2 +- backend/src/main/java/hanglog/like/domain/MemberLike.java | 2 +- backend/src/main/java/hanglog/like/service/LikeService.java | 4 ++-- .../integration/service/LikeServiceIntegrationTest.java | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/hanglog/community/service/CommunityService.java b/backend/src/main/java/hanglog/community/service/CommunityService.java index 2b1cb4c7e..c23bbc041 100644 --- a/backend/src/main/java/hanglog/community/service/CommunityService.java +++ b/backend/src/main/java/hanglog/community/service/CommunityService.java @@ -145,7 +145,7 @@ private LikeElement getLikeElement(final Long memberId, final Long tripId) { final Optional likeCount = likeCountRepository.findById(tripId); final Optional memberLike = memberLikeRepository.findById(memberId); if (likeCount.isPresent() && memberLike.isPresent()) { - final Map tripLikeStatusMap = memberLike.get().getTripLikeStatusMap(); + final Map tripLikeStatusMap = memberLike.get().getLikeStatusForTrip(); if (tripLikeStatusMap.containsKey(tripId)) { return new LikeElement(tripId, likeCount.get().getCount(), tripLikeStatusMap.get(tripId)); } diff --git a/backend/src/main/java/hanglog/like/domain/MemberLike.java b/backend/src/main/java/hanglog/like/domain/MemberLike.java index aefadb2a2..50101bee5 100644 --- a/backend/src/main/java/hanglog/like/domain/MemberLike.java +++ b/backend/src/main/java/hanglog/like/domain/MemberLike.java @@ -14,5 +14,5 @@ public class MemberLike { @Id private Long memberId; - private Map tripLikeStatusMap; + private Map likeStatusForTrip; } diff --git a/backend/src/main/java/hanglog/like/service/LikeService.java b/backend/src/main/java/hanglog/like/service/LikeService.java index 5d297c971..fc4799265 100644 --- a/backend/src/main/java/hanglog/like/service/LikeService.java +++ b/backend/src/main/java/hanglog/like/service/LikeService.java @@ -35,7 +35,7 @@ public void update(final Long memberId, final Long tripId, final LikeRequest lik Map tripLikeStatusMap = new HashMap<>(); final Optional memberLike = memberLikeRepository.findById(memberId); if (memberLike.isPresent()) { - tripLikeStatusMap = memberLike.get().getTripLikeStatusMap(); + tripLikeStatusMap = memberLike.get().getLikeStatusForTrip(); } tripLikeStatusMap.put(tripId, likeRequest.getIsLike()); memberLikeRepository.save(new MemberLike(memberId, tripLikeStatusMap)); @@ -55,7 +55,7 @@ private void updateLikeCountCache(final Long tripId, final LikeRequest likeReque public void writeBackMemberLikeCache() { final List likes = memberRepository.findAll().stream() .flatMap(member -> memberLikeRepository.findById(member.getId()) - .map(memberLike -> memberLike.getTripLikeStatusMap() + .map(memberLike -> memberLike.getLikeStatusForTrip() .entrySet().stream() .filter(Map.Entry::getValue) .map(entry -> new Likes(entry.getKey(), member.getId()))) diff --git a/backend/src/test/java/hanglog/integration/service/LikeServiceIntegrationTest.java b/backend/src/test/java/hanglog/integration/service/LikeServiceIntegrationTest.java index 93f69c386..843d661e9 100644 --- a/backend/src/test/java/hanglog/integration/service/LikeServiceIntegrationTest.java +++ b/backend/src/test/java/hanglog/integration/service/LikeServiceIntegrationTest.java @@ -39,14 +39,14 @@ void update() { softly.assertThat(memberLikeRepository.findById(member.getId())).isPresent(); softly.assertThat(memberLikeRepository.findById(member.getId()) .get() - .getTripLikeStatusMap() + .getLikeStatusForTrip() .get(tripId)).isTrue(); likeService.update(member.getId(), tripId, likeFalseRequest); softly.assertThat(memberLikeRepository.findById(member.getId())).isPresent(); softly.assertThat(memberLikeRepository.findById(member.getId()) .get() - .getTripLikeStatusMap() + .getLikeStatusForTrip() .get(tripId)).isFalse(); }); }