From 0e1b1ae0e37d172357897015de8a5e99d4e99228 Mon Sep 17 00:00:00 2001 From: jeong724 Date: Tue, 14 Jan 2025 16:43:00 +0900 Subject: [PATCH 1/5] =?UTF-8?q?refactor=20:=20popularpost=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=82=AD=EC=A0=9C,=20=EB=A0=88=ED=8F=AC?= =?UTF-8?q?=EC=A7=80=ED=86=A0=EB=A6=AC=20=EC=82=AD=EC=A0=9C,=20=EC=96=B4?= =?UTF-8?q?=EC=A0=9C=EA=B9=8C=EC=A7=80=20=EC=A2=8B=EC=95=84=EC=9A=94=20?= =?UTF-8?q?=EB=A7=8E=EC=9D=80=20=EA=B8=80=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EB=8A=94=20=EC=BF=BC=EB=A6=AC=EB=AC=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reflog/postlike/domain/PopularPost.java | 24 ---------- .../reflog/postlike/domain/PostLike.java | 5 ++ .../repository/PopularPostRepository.java | 7 --- .../repository/PostLikeRepository.java | 8 ++-- .../postlike/service/PopularScheduler.java | 48 ------------------- .../postlike/service/PostLikeService.java | 23 +++++---- 6 files changed, 25 insertions(+), 90 deletions(-) delete mode 100644 src/main/java/itstime/reflog/postlike/domain/PopularPost.java delete mode 100644 src/main/java/itstime/reflog/postlike/repository/PopularPostRepository.java delete mode 100644 src/main/java/itstime/reflog/postlike/service/PopularScheduler.java diff --git a/src/main/java/itstime/reflog/postlike/domain/PopularPost.java b/src/main/java/itstime/reflog/postlike/domain/PopularPost.java deleted file mode 100644 index b02ab0a..0000000 --- a/src/main/java/itstime/reflog/postlike/domain/PopularPost.java +++ /dev/null @@ -1,24 +0,0 @@ -package itstime.reflog.postlike.domain; - -import itstime.reflog.postlike.domain.enums.PostType; -import jakarta.persistence.*; -import lombok.*; - -import java.util.List; - -@Entity -@Getter -@Builder -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor -public class PopularPost { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(nullable = false) - private Long postId; - - @Enumerated(EnumType.STRING) - private PostType postType; -} diff --git a/src/main/java/itstime/reflog/postlike/domain/PostLike.java b/src/main/java/itstime/reflog/postlike/domain/PostLike.java index 158aa3b..250a3f1 100644 --- a/src/main/java/itstime/reflog/postlike/domain/PostLike.java +++ b/src/main/java/itstime/reflog/postlike/domain/PostLike.java @@ -9,6 +9,8 @@ import jakarta.persistence.*; import lombok.*; +import java.time.LocalDate; + @Entity @Getter @Builder @@ -35,6 +37,9 @@ public class PostLike { @Enumerated(EnumType.STRING) private PostType postType; + @Column(name = "created_date") + private LocalDate createdDate; + @Enumerated(EnumType.STRING) private LikeType likeType; //북마크인지 좋아요인지 구분하기 위해 diff --git a/src/main/java/itstime/reflog/postlike/repository/PopularPostRepository.java b/src/main/java/itstime/reflog/postlike/repository/PopularPostRepository.java deleted file mode 100644 index cdf5f80..0000000 --- a/src/main/java/itstime/reflog/postlike/repository/PopularPostRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package itstime.reflog.postlike.repository; - -import itstime.reflog.postlike.domain.PopularPost; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface PopularPostRepository extends JpaRepository { -} diff --git a/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java b/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java index 0856d61..f526f8d 100644 --- a/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java +++ b/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java @@ -42,15 +42,17 @@ public interface PostLikeRepository extends JpaRepository { //community 게시물 좋아요 많은 순으로 정렬하고 id, 좋아요 수 반환 : Object[0] = id, Object[1] = 좋아요 수 //타입을 구분하기 위해 앞에 타입도 반환 - @Query("SELECT 'COMMUNITY', pl.community.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'COMMUNITY' AND pl.likeType = 'LIKE' GROUP BY pl.community.id " + + @Query("SELECT 'COMMUNITY', pl.community.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'COMMUNITY' AND pl.likeType = 'LIKE' AND pl.createdDate < CURRENT_DATE GROUP BY pl.community.id " + "ORDER BY likeCount DESC") List findCommunityByPostLikeTop(); - //retrospect 게시물 좋아요 많은 순으로 정렬 - @Query("SELECT 'RETROSPECT', pl.retrospect.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'RETROSPECT' AND pl.likeType = 'LIKE' GROUP BY pl.retrospect.id " + + //retrospect 게시물 좋아요 많은 순으로 정렬 + 어제까지의 데이터 중에서만 + @Query("SELECT 'RETROSPECT', pl.retrospect.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'RETROSPECT' AND pl.likeType = 'LIKE' AND pl.createdDate < CURRENT_DATE GROUP BY pl.retrospect.id " + "ORDER BY likeCount DESC") List findARetrospectPostLikesTop(); @Query("SELECT pl from PostLike pl WHERE pl.likeType = 'BOOKMARK' AND pl.member = :member") List findPostLikesByMember(@Param("member") Member member); + + } diff --git a/src/main/java/itstime/reflog/postlike/service/PopularScheduler.java b/src/main/java/itstime/reflog/postlike/service/PopularScheduler.java deleted file mode 100644 index eaec33e..0000000 --- a/src/main/java/itstime/reflog/postlike/service/PopularScheduler.java +++ /dev/null @@ -1,48 +0,0 @@ -package itstime.reflog.postlike.service; - -import itstime.reflog.postlike.domain.PopularPost; -import itstime.reflog.postlike.domain.PostLike; -import itstime.reflog.postlike.domain.enums.PostType; -import itstime.reflog.postlike.repository.PopularPostRepository; -import itstime.reflog.postlike.repository.PostLikeRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; - -@Service -@RequiredArgsConstructor -public class PopularScheduler { - - private final PostLikeRepository postLikeRepository; - private final PopularPostRepository popularPostRepository; - - @Scheduled(cron = "0 0 0 * * *") - public void scheduledPopularPosts() { - - //1. 이전에 있던 인기글 목록 지우기 - popularPostRepository.deleteAll(); - - //2. 커뮤니티, 회고일지 좋아요 순으로 각각 가져와서 하나의 배열에 저장 - List postLikesTop = new ArrayList<>(postLikeRepository.findCommunityByPostLikeTop()); - postLikesTop.addAll(postLikeRepository.findARetrospectPostLikesTop()); - - //좋아요 수인 object[1]이 Object 타입이기 떄문에 Long 타입으로 바꿔 준 후 비교 정렬 - postLikesTop.sort((o1, o2) -> Long.compare((Long) o2[2], (Long) o1[2])); - - //이 중 상위 세개만 가져옴 - List postLikesTopThree = postLikesTop.stream().limit(3).toList(); - - //가져온 데이터 저장 - for (Object[] postLike : postLikesTopThree) { - - PopularPost popularPost = PopularPost.builder() - .postId((Long) postLike[1]) - .postType(PostType.valueOf((String) postLike[0])) - .build(); - popularPostRepository.save(popularPost); - } - } -} diff --git a/src/main/java/itstime/reflog/postlike/service/PostLikeService.java b/src/main/java/itstime/reflog/postlike/service/PostLikeService.java index 55522a9..8fe8986 100644 --- a/src/main/java/itstime/reflog/postlike/service/PostLikeService.java +++ b/src/main/java/itstime/reflog/postlike/service/PostLikeService.java @@ -12,19 +12,18 @@ import itstime.reflog.mypage.repository.MyPageRepository; import itstime.reflog.notification.domain.NotificationType; import itstime.reflog.notification.service.NotificationService; -import itstime.reflog.postlike.domain.PopularPost; import itstime.reflog.member.service.MemberServiceHelper; import itstime.reflog.mission.service.MissionService; import itstime.reflog.postlike.domain.PostLike; import itstime.reflog.postlike.domain.enums.LikeType; import itstime.reflog.postlike.domain.enums.PostType; import itstime.reflog.postlike.dto.PostLikeDto; -import itstime.reflog.postlike.repository.PopularPostRepository; import itstime.reflog.postlike.repository.PostLikeRepository; import itstime.reflog.retrospect.domain.Retrospect; import itstime.reflog.retrospect.repository.RetrospectRepository; import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import static itstime.reflog.mission.domain.Badge.POWER_OF_HEART; @@ -33,6 +32,7 @@ import java.util.List; import java.util.stream.Collectors; +@Slf4j @Service @RequiredArgsConstructor public class PostLikeService { @@ -40,7 +40,6 @@ public class PostLikeService { private final CommunityRepository communityRepository; private final RetrospectRepository retrospectRepository; private final MyPageRepository myPageRepository; - private final PopularPostRepository popularPostRepository; private final MemberServiceHelper memberServiceHelper; private final MissionService missionService; private final CommentRepository commentRepository; @@ -193,12 +192,20 @@ public int getSumRetrospectPostLike(Retrospect retrospect) { public List getTopLikeCommunityPosts(String memberId) { Member member = memberServiceHelper.findMemberByUuid(memberId); - List postLikesTopThree = popularPostRepository.findAll(); + //2. 커뮤니티, 회고일지 좋아요 순으로 각각 가져와서 하나의 배열에 저장 + List postLikesTop = new ArrayList<>(postLikeRepository.findCommunityByPostLikeTop()); + postLikesTop.addAll(postLikeRepository.findARetrospectPostLikesTop()); + + //좋아요 수인 object[1]이 Object 타입이기 떄문에 Long 타입으로 바꿔 준 후 비교 정렬 + postLikesTop.sort((o1, o2) -> Long.compare((Long) o2[2], (Long) o1[2])); + + //이 중 상위 세개만 가져옴 + List postLikesTopThree = postLikesTop.stream().limit(3).toList(); return postLikesTopThree.stream() .map(popularPost -> { - if (popularPost.getPostType() == PostType.COMMUNITY) { - Community community = communityRepository.findById(popularPost.getPostId()) + if (popularPost[0] == PostType.COMMUNITY) { + Community community = communityRepository.findById((Long)popularPost[1]) .orElseThrow(() -> new GeneralException(ErrorStatus._POST_NOT_FOUND)); String nickname = myPageRepository.findByMember(community.getMember()) .map(MyPage::getNickname) @@ -211,8 +218,8 @@ public List getTopLikeCommunityPosts(Stri return CommunityDto.CombinedCategoryResponse.fromCommunity(community, nickname, isLike, totalLike, totalComment); - } else if (popularPost.getPostType() == PostType.RETROSPECT) { - Retrospect retrospect = retrospectRepository.findById(popularPost.getPostId()) + } else if (popularPost[0] == PostType.RETROSPECT) { + Retrospect retrospect = retrospectRepository.findById((Long)popularPost[1]) .orElseThrow(() -> new GeneralException(ErrorStatus._POST_NOT_FOUND)); String nickname = myPageRepository.findByMember(retrospect.getMember()) .map(MyPage::getNickname) From 1a59cf916d530a8643373294edc666308809e86c Mon Sep 17 00:00:00 2001 From: jeong724 Date: Tue, 14 Jan 2025 17:04:45 +0900 Subject: [PATCH 2/5] =?UTF-8?q?fix=20:=20object=ED=83=80=EC=9E=85=EC=9D=84?= =?UTF-8?q?=20enum=20=ED=83=80=EC=9E=85=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reflog/postlike/repository/PostLikeRepository.java | 4 ++-- .../itstime/reflog/postlike/service/PostLikeService.java | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java b/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java index f526f8d..7f04a22 100644 --- a/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java +++ b/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java @@ -42,12 +42,12 @@ public interface PostLikeRepository extends JpaRepository { //community 게시물 좋아요 많은 순으로 정렬하고 id, 좋아요 수 반환 : Object[0] = id, Object[1] = 좋아요 수 //타입을 구분하기 위해 앞에 타입도 반환 - @Query("SELECT 'COMMUNITY', pl.community.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'COMMUNITY' AND pl.likeType = 'LIKE' AND pl.createdDate < CURRENT_DATE GROUP BY pl.community.id " + + @Query("SELECT 'COMMUNITY', pl.community.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'COMMUNITY' AND pl.likeType = 'LIKE' AND pl.createdDate <= CURRENT_DATE GROUP BY pl.community.id " + "ORDER BY likeCount DESC") List findCommunityByPostLikeTop(); //retrospect 게시물 좋아요 많은 순으로 정렬 + 어제까지의 데이터 중에서만 - @Query("SELECT 'RETROSPECT', pl.retrospect.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'RETROSPECT' AND pl.likeType = 'LIKE' AND pl.createdDate < CURRENT_DATE GROUP BY pl.retrospect.id " + + @Query("SELECT 'RETROSPECT', pl.retrospect.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'RETROSPECT' AND pl.likeType = 'LIKE' AND pl.createdDate <= CURRENT_DATE GROUP BY pl.retrospect.id " + "ORDER BY likeCount DESC") List findARetrospectPostLikesTop(); diff --git a/src/main/java/itstime/reflog/postlike/service/PostLikeService.java b/src/main/java/itstime/reflog/postlike/service/PostLikeService.java index 8fe8986..278f2d1 100644 --- a/src/main/java/itstime/reflog/postlike/service/PostLikeService.java +++ b/src/main/java/itstime/reflog/postlike/service/PostLikeService.java @@ -28,6 +28,7 @@ import static itstime.reflog.mission.domain.Badge.POWER_OF_HEART; +import java.time.LocalDate; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -76,6 +77,7 @@ public void togglePostLike(String memberId, Long postId, PostLikeDto.PostLikeSav PostLike newPostLike = PostLike.builder() .member(member) .community(community) + .createdDate(LocalDate.now()) .postType(PostType.COMMUNITY) .likeType(LikeType.LIKE) //좋아요 .build(); @@ -102,6 +104,7 @@ public void togglePostLike(String memberId, Long postId, PostLikeDto.PostLikeSav PostLike newPostLike = PostLike.builder() .member(member) .community(community) + .createdDate(LocalDate.now()) .postType(PostType.COMMUNITY) .likeType(LikeType.BOOKMARK) //북마크 .build(); @@ -133,6 +136,7 @@ else if (PostType.RETROSPECT == PostType.valueOf(dto.getPostType())){ .member(member) .retrospect(retrospect) .postType(PostType.RETROSPECT) + .createdDate(LocalDate.now()) .likeType(LikeType.LIKE) .build(); @@ -160,6 +164,7 @@ else if (PostType.RETROSPECT == PostType.valueOf(dto.getPostType())){ .member(member) .retrospect(retrospect) .postType(PostType.RETROSPECT) + .createdDate(LocalDate.now()) .likeType(LikeType.BOOKMARK) //북마크 .build(); @@ -204,7 +209,8 @@ public List getTopLikeCommunityPosts(Stri return postLikesTopThree.stream() .map(popularPost -> { - if (popularPost[0] == PostType.COMMUNITY) { + log.debug("인기글 조회", (String) popularPost[0]); + if (PostType.valueOf((String) popularPost[0]) == PostType.COMMUNITY) { Community community = communityRepository.findById((Long)popularPost[1]) .orElseThrow(() -> new GeneralException(ErrorStatus._POST_NOT_FOUND)); String nickname = myPageRepository.findByMember(community.getMember()) From 0142b2b39786052a4b1d9f820cabf0cd1692dafc Mon Sep 17 00:00:00 2001 From: jeong724 Date: Tue, 14 Jan 2025 17:06:55 +0900 Subject: [PATCH 3/5] =?UTF-8?q?refactor=20:=20=EC=9D=B8=EA=B8=B0=EA=B8=80?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20api=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../itstime/reflog/postlike/service/PostLikeService.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/itstime/reflog/postlike/service/PostLikeService.java b/src/main/java/itstime/reflog/postlike/service/PostLikeService.java index 278f2d1..f04f145 100644 --- a/src/main/java/itstime/reflog/postlike/service/PostLikeService.java +++ b/src/main/java/itstime/reflog/postlike/service/PostLikeService.java @@ -197,19 +197,18 @@ public int getSumRetrospectPostLike(Retrospect retrospect) { public List getTopLikeCommunityPosts(String memberId) { Member member = memberServiceHelper.findMemberByUuid(memberId); - //2. 커뮤니티, 회고일지 좋아요 순으로 각각 가져와서 하나의 배열에 저장 + //1. 커뮤니티, 회고일지 좋아요 순으로 각각 가져와서 하나의 배열에 저장 List postLikesTop = new ArrayList<>(postLikeRepository.findCommunityByPostLikeTop()); postLikesTop.addAll(postLikeRepository.findARetrospectPostLikesTop()); - //좋아요 수인 object[1]이 Object 타입이기 떄문에 Long 타입으로 바꿔 준 후 비교 정렬 + //2. 좋아요 수인 object[1]이 Object 타입이기 떄문에 Long 타입으로 바꿔 준 후 비교 정렬 postLikesTop.sort((o1, o2) -> Long.compare((Long) o2[2], (Long) o1[2])); - //이 중 상위 세개만 가져옴 + //3. 이 중 상위 세개만 가져옴 List postLikesTopThree = postLikesTop.stream().limit(3).toList(); return postLikesTopThree.stream() .map(popularPost -> { - log.debug("인기글 조회", (String) popularPost[0]); if (PostType.valueOf((String) popularPost[0]) == PostType.COMMUNITY) { Community community = communityRepository.findById((Long)popularPost[1]) .orElseThrow(() -> new GeneralException(ErrorStatus._POST_NOT_FOUND)); From 7b8529930fa66882833858290d5077b77ec07b49 Mon Sep 17 00:00:00 2001 From: jeong724 Date: Tue, 14 Jan 2025 17:07:59 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix=20:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=9C=84=ED=95=B4=20=EC=98=A4=EB=8A=98=EB=A1=9C=20=EB=B0=94?= =?UTF-8?q?=EA=BF=A8=EB=8D=98=EA=B1=B0=20=EC=96=B4=EC=A0=9C=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reflog/postlike/repository/PostLikeRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java b/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java index 7f04a22..f526f8d 100644 --- a/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java +++ b/src/main/java/itstime/reflog/postlike/repository/PostLikeRepository.java @@ -42,12 +42,12 @@ public interface PostLikeRepository extends JpaRepository { //community 게시물 좋아요 많은 순으로 정렬하고 id, 좋아요 수 반환 : Object[0] = id, Object[1] = 좋아요 수 //타입을 구분하기 위해 앞에 타입도 반환 - @Query("SELECT 'COMMUNITY', pl.community.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'COMMUNITY' AND pl.likeType = 'LIKE' AND pl.createdDate <= CURRENT_DATE GROUP BY pl.community.id " + + @Query("SELECT 'COMMUNITY', pl.community.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'COMMUNITY' AND pl.likeType = 'LIKE' AND pl.createdDate < CURRENT_DATE GROUP BY pl.community.id " + "ORDER BY likeCount DESC") List findCommunityByPostLikeTop(); //retrospect 게시물 좋아요 많은 순으로 정렬 + 어제까지의 데이터 중에서만 - @Query("SELECT 'RETROSPECT', pl.retrospect.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'RETROSPECT' AND pl.likeType = 'LIKE' AND pl.createdDate <= CURRENT_DATE GROUP BY pl.retrospect.id " + + @Query("SELECT 'RETROSPECT', pl.retrospect.id, COUNT(pl) as likeCount FROM PostLike pl WHERE pl.postType = 'RETROSPECT' AND pl.likeType = 'LIKE' AND pl.createdDate < CURRENT_DATE GROUP BY pl.retrospect.id " + "ORDER BY likeCount DESC") List findARetrospectPostLikesTop(); From 9c23c6fb0067d540d652e274e752e0d344a0a9a8 Mon Sep 17 00:00:00 2001 From: jeong724 Date: Tue, 14 Jan 2025 17:22:07 +0900 Subject: [PATCH 5/5] =?UTF-8?q?refactor=20:=20=EC=9D=B8=EA=B8=B0=EA=B8=80?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20api=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/itstime/reflog/postlike/service/PostLikeService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/itstime/reflog/postlike/service/PostLikeService.java b/src/main/java/itstime/reflog/postlike/service/PostLikeService.java index f04f145..1299add 100644 --- a/src/main/java/itstime/reflog/postlike/service/PostLikeService.java +++ b/src/main/java/itstime/reflog/postlike/service/PostLikeService.java @@ -70,7 +70,7 @@ public void togglePostLike(String memberId, Long postId, PostLikeDto.PostLikeSav //2.좋아요 존재 여부 확인 if (postLike != null && postLike.getLikeType().equals(LikeType.LIKE)) { - //좋아요가 이미 있다면 테이블 삭제 + //좋아요가 이미 있다면 엔티티 삭제 postLikeRepository.delete(postLike); } else { //좋아요가 없다면 테이블 생성 @@ -148,7 +148,6 @@ else if (PostType.RETROSPECT == PostType.valueOf(dto.getPostType())){ // 알림 sendRetrospectLikeNotification(retrospect, member); - } } else if (LikeType.BOOKMARK == LikeType.valueOf(dto.getLikeType())) { //북마크한경우 //커뮤니티, 멤버 id와 일치하는 북마크 가져오기 @@ -158,6 +157,7 @@ else if (PostType.RETROSPECT == PostType.valueOf(dto.getPostType())){ if (postLike != null && postLike.getLikeType().equals(LikeType.BOOKMARK)) { //북마크가 이미 있다면 테이블 삭제 postLikeRepository.delete(postLike); + } else { //좋아요가 없다면 테이블 생성 PostLike newPostLike = PostLike.builder()