From 1c3f84da4e942a0506ef599e343ae1eb90913234 Mon Sep 17 00:00:00 2001 From: chaeyoungeee Date: Wed, 31 Jul 2024 15:45:23 +0900 Subject: [PATCH 01/12] =?UTF-8?q?feat:=20=ED=9B=84=EA=B8=B0=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/review/ReviewController.java | 10 +++ .../review/response/ReviewDetailResponse.java | 76 +++++++++++++++++++ .../service/review/ReviewService.java | 6 ++ 3 files changed, 92 insertions(+) create mode 100644 src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java diff --git a/src/main/java/likelion/MZConnent/api/review/ReviewController.java b/src/main/java/likelion/MZConnent/api/review/ReviewController.java index 140cd9a..6e8fa6e 100644 --- a/src/main/java/likelion/MZConnent/api/review/ReviewController.java +++ b/src/main/java/likelion/MZConnent/api/review/ReviewController.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import likelion.MZConnent.dto.paging.response.PageContentResponse; import likelion.MZConnent.dto.review.request.SaveReviewRequest; +import likelion.MZConnent.dto.review.response.ReviewDetailResponse; import likelion.MZConnent.dto.review.response.ReviewsSimpleResponse; import likelion.MZConnent.dto.review.response.SaveReviewResponse; import likelion.MZConnent.jwt.principle.UserPrinciple; @@ -71,4 +72,13 @@ public ResponseEntity> toggleReviewLike(@PathVariable("revie return ResponseEntity.ok(Map.of("message", "후기 좋아요 삭제 성공")); } } + + + // 후기 상세 정보 조회 + @GetMapping("/api/reviews/{reviewId}") + public ResponseEntity getReviewDetailInfo(@PathVariable("reviewId") Long reviewId) { + ReviewDetailResponse response = reviewService.getReviewDetailInfo(reviewId); + log.info("후기 상세 정보: {}", response); + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java b/src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java new file mode 100644 index 0000000..24d9540 --- /dev/null +++ b/src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java @@ -0,0 +1,76 @@ +package likelion.MZConnent.dto.review.response; + +import likelion.MZConnent.domain.culture.Culture; +import likelion.MZConnent.domain.review.Review; +import likelion.MZConnent.domain.review.ReviewComment; +import likelion.MZConnent.dto.member.MemberProfileDto; +import lombok.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@Getter +@ToString +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class ReviewDetailResponse { + private Long reviewId; + private MemberProfileDto reviewer; + private CultureSimpleDto culture; + private String title; + private String reviewImageUrl1; + private String reviewImageUrl2; + private String reviewImageUrl3; + private String reviewImageUrl4; + private LocalDateTime createdDate; + private int likeCount; + private List comments = new ArrayList(); + + @Builder + public ReviewDetailResponse(Review review) { + this.reviewId = review.getReviewId(); + this.reviewer = MemberProfileDto.builder().member(review.getMember()).build(); + this.culture = CultureSimpleDto.builder().culture(review.getCulture()).build(); + this.title = review.getTitle(); + this.reviewImageUrl1 = review.getReviewImageUrl1(); + this.reviewImageUrl2 = review.getReviewImageUrl2(); + this.reviewImageUrl3 = review.getReviewImageUrl3(); + this.reviewImageUrl4 = review.getReviewImageUrl4(); + this.createdDate = review.getCreatedDate(); + this.likeCount = review.getLikeCount(); + this.comments = review.getReviewComments().stream() + .map(CommentSimpleDto::new).collect(Collectors.toList()); + } + + @Getter + @ToString + @NoArgsConstructor(access = AccessLevel.PROTECTED) + private static class CultureSimpleDto { + private Long cultureId; + private String name; + + @Builder + public CultureSimpleDto(Culture culture) { + this.cultureId = culture.getCultureId(); + this.name = culture.getName(); + } + } + + @Getter + @ToString + @NoArgsConstructor(access = AccessLevel.PROTECTED) + private static class CommentSimpleDto { + private Long commentId; + private MemberProfileDto commenter; + private String content; + + @Builder + public CommentSimpleDto(ReviewComment comment) { + this.commentId = comment.getCommentId(); + this.commenter = MemberProfileDto.builder().member(comment.getMember()).build(); + this.content = comment.getContent(); + } + } + +} diff --git a/src/main/java/likelion/MZConnent/service/review/ReviewService.java b/src/main/java/likelion/MZConnent/service/review/ReviewService.java index e8587d3..8ceceb4 100644 --- a/src/main/java/likelion/MZConnent/service/review/ReviewService.java +++ b/src/main/java/likelion/MZConnent/service/review/ReviewService.java @@ -8,6 +8,7 @@ import likelion.MZConnent.domain.review.ReviewLike; import likelion.MZConnent.dto.paging.response.PageContentResponse; import likelion.MZConnent.dto.review.request.SaveReviewRequest; +import likelion.MZConnent.dto.review.response.ReviewDetailResponse; import likelion.MZConnent.dto.review.response.ReviewsSimpleResponse; import likelion.MZConnent.dto.review.response.SaveReviewResponse; import likelion.MZConnent.repository.culture.CultureRepository; @@ -151,6 +152,11 @@ public boolean toggleReviewLike(String email, Long reviewId) { } } + // 후기 상세 정보 조회 + public ReviewDetailResponse getReviewDetailInfo(Long reviewId) { + return ReviewDetailResponse.builder().review(findReviewById(reviewId)).build(); + } + private Review findReviewById(Long reviewId) { return reviewRepository.findById(reviewId).orElseThrow(() -> { log.info("후기 정보를 찾을 수 없음."); From 4c29d4c9046fe5f847366db4267d06279dedc15f Mon Sep 17 00:00:00 2001 From: Chaeyoung Lim <102286483+chaeyoungeee@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:20:04 +0900 Subject: [PATCH 02/12] Update gradle.yml --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 39284dc..d282799 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -58,7 +58,7 @@ jobs: run-docker-image-on-ec2: #cd needs: build-docker-image - runs-on: self-hosted + runs-on: ubuntu-latest steps: From dcba5cb55ebb791a91973997919f93ec2958a8f6 Mon Sep 17 00:00:00 2001 From: Chaeyoung Lim <102286483+chaeyoungeee@users.noreply.github.com> Date: Thu, 1 Aug 2024 02:25:10 +0900 Subject: [PATCH 03/12] Update gradle.yml --- .github/workflows/gradle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index d282799..39284dc 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -58,7 +58,7 @@ jobs: run-docker-image-on-ec2: #cd needs: build-docker-image - runs-on: ubuntu-latest + runs-on: self-hosted steps: From 4b0e943dc4cc677fad18ee2c9c534288030027cd Mon Sep 17 00:00:00 2001 From: chaeyoungeee Date: Thu, 1 Aug 2024 19:59:34 +0900 Subject: [PATCH 04/12] =?UTF-8?q?feat:=20=ED=9B=84=EA=B8=B0=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/review/ReviewController.java | 6 +++++ .../review/ReviewCommentRepository.java | 5 +++++ .../review/ReviewLikeRepository.java | 3 +++ .../service/review/ReviewService.java | 22 +++++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/src/main/java/likelion/MZConnent/api/review/ReviewController.java b/src/main/java/likelion/MZConnent/api/review/ReviewController.java index 6e8fa6e..a9abd9c 100644 --- a/src/main/java/likelion/MZConnent/api/review/ReviewController.java +++ b/src/main/java/likelion/MZConnent/api/review/ReviewController.java @@ -81,4 +81,10 @@ public ResponseEntity getReviewDetailInfo(@PathVariable("r log.info("후기 상세 정보: {}", response); return ResponseEntity.ok(response); } + + @DeleteMapping("/api/reviews/{reviewId}") + public ResponseEntity> deleteReview(@PathVariable("reviewId") Long reviewId) { + reviewService.deleteReview(reviewId); + return ResponseEntity.ok(Map.of("message", "후기 삭제 성공")); + } } diff --git a/src/main/java/likelion/MZConnent/repository/review/ReviewCommentRepository.java b/src/main/java/likelion/MZConnent/repository/review/ReviewCommentRepository.java index d0ffc9a..53555a2 100644 --- a/src/main/java/likelion/MZConnent/repository/review/ReviewCommentRepository.java +++ b/src/main/java/likelion/MZConnent/repository/review/ReviewCommentRepository.java @@ -1,10 +1,15 @@ package likelion.MZConnent.repository.review; +import likelion.MZConnent.domain.review.Review; import likelion.MZConnent.domain.review.ReviewComment; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; +import java.util.Optional; + @Repository public interface ReviewCommentRepository extends JpaRepository { + List findAllByReview(Review review); } diff --git a/src/main/java/likelion/MZConnent/repository/review/ReviewLikeRepository.java b/src/main/java/likelion/MZConnent/repository/review/ReviewLikeRepository.java index d83a486..ab29a58 100644 --- a/src/main/java/likelion/MZConnent/repository/review/ReviewLikeRepository.java +++ b/src/main/java/likelion/MZConnent/repository/review/ReviewLikeRepository.java @@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; import java.util.Optional; @Repository @@ -16,4 +17,6 @@ public interface ReviewLikeRepository extends JpaRepository { boolean existsByMemberAndReview(Member member, Review review); Optional findByMemberAndReview(Member member, Review review); + + List findAllByReview(Review review); } diff --git a/src/main/java/likelion/MZConnent/service/review/ReviewService.java b/src/main/java/likelion/MZConnent/service/review/ReviewService.java index 8ceceb4..82323b7 100644 --- a/src/main/java/likelion/MZConnent/service/review/ReviewService.java +++ b/src/main/java/likelion/MZConnent/service/review/ReviewService.java @@ -5,6 +5,7 @@ import likelion.MZConnent.domain.culture.CultureInterest; import likelion.MZConnent.domain.member.Member; import likelion.MZConnent.domain.review.Review; +import likelion.MZConnent.domain.review.ReviewComment; import likelion.MZConnent.domain.review.ReviewLike; import likelion.MZConnent.dto.paging.response.PageContentResponse; import likelion.MZConnent.dto.review.request.SaveReviewRequest; @@ -13,6 +14,7 @@ import likelion.MZConnent.dto.review.response.SaveReviewResponse; import likelion.MZConnent.repository.culture.CultureRepository; import likelion.MZConnent.repository.member.MemberRepository; +import likelion.MZConnent.repository.review.ReviewCommentRepository; import likelion.MZConnent.repository.review.ReviewLikeRepository; import likelion.MZConnent.repository.review.ReviewRepository; import likelion.MZConnent.service.image.S3ImageService; @@ -29,6 +31,7 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; @Service @@ -41,6 +44,8 @@ public class ReviewService { private final MemberRepository memberRepository; private final CultureRepository cultureRepository; private final ReviewLikeRepository reviewLikeRepository; + private final ReviewCommentRepository reviewCommentRepository; + private final int PAGE_SIZE = 6; public PageContentResponse getReviewsSimpleList(String keyword, int page) { @@ -176,4 +181,21 @@ private Member findMemberByEmail(String email) { return new IllegalArgumentException("회원 정보를 찾을 수 없습니다."); }); } + + public void deleteReview(Long reviewId) { + Review review = findReviewById(reviewId); + // 후기 댓글 삭제 + List comments = reviewCommentRepository.findAllByReview(review); + comments.forEach(comment -> review.getMember().getReviewComments().remove(comment)); + reviewCommentRepository.deleteAll(comments); + + // 후기 좋아요 삭제 + List likes = reviewLikeRepository.findAllByReview(review); + likes.forEach(like -> like.getMember().getReviewLikes().remove(like)); + reviewLikeRepository.deleteAll(likes); + + // 후기 삭제 + review.getCulture().getReviews().remove(review); + reviewRepository.delete(review); + } } From 190876b50fdfdb12b17a26e859a7e8038596eab6 Mon Sep 17 00:00:00 2001 From: chaeyoungeee Date: Thu, 1 Aug 2024 20:59:33 +0900 Subject: [PATCH 05/12] =?UTF-8?q?feat:=20=EB=A9=94=EC=9D=B8=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/main/MainInfoController.java | 25 ++++++++++ .../dto/club/response/ClubSimpleResponse.java | 33 +++++++++++-- .../response/CultureDetailResponse.java | 47 ++----------------- .../dto/main/response/MainInfoResponse.java | 30 ++++++++++++ .../repository/club/ClubRepository.java | 4 ++ .../repository/culture/CultureRepository.java | 6 +++ .../repository/review/ReviewRepository.java | 4 ++ .../service/club/ClubInfoService.java | 4 +- .../service/main/MainInfoService.java | 41 ++++++++++++++++ .../service/main/MainInfoServiceTest.java | 4 ++ 10 files changed, 150 insertions(+), 48 deletions(-) create mode 100644 src/main/java/likelion/MZConnent/api/main/MainInfoController.java create mode 100644 src/main/java/likelion/MZConnent/dto/main/response/MainInfoResponse.java create mode 100644 src/main/java/likelion/MZConnent/service/main/MainInfoService.java create mode 100644 src/test/java/likelion/MZConnent/service/main/MainInfoServiceTest.java diff --git a/src/main/java/likelion/MZConnent/api/main/MainInfoController.java b/src/main/java/likelion/MZConnent/api/main/MainInfoController.java new file mode 100644 index 0000000..4526bd3 --- /dev/null +++ b/src/main/java/likelion/MZConnent/api/main/MainInfoController.java @@ -0,0 +1,25 @@ +package likelion.MZConnent.api.main; + +import likelion.MZConnent.dto.main.response.MainInfoResponse; +import likelion.MZConnent.service.main.MainInfoService; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Slf4j +@RequiredArgsConstructor +public class MainInfoController { + private final MainInfoService mainInfoService; + + @GetMapping("/api/main") + public ResponseEntity getMainInfo() { + MainInfoResponse mainInfo = mainInfoService.getMainInfo(); + log.info("메인 정보 조회: {}", mainInfo); + + return ResponseEntity.ok(mainInfo); + } +} diff --git a/src/main/java/likelion/MZConnent/dto/club/response/ClubSimpleResponse.java b/src/main/java/likelion/MZConnent/dto/club/response/ClubSimpleResponse.java index 451a7d1..35c8a16 100644 --- a/src/main/java/likelion/MZConnent/dto/club/response/ClubSimpleResponse.java +++ b/src/main/java/likelion/MZConnent/dto/club/response/ClubSimpleResponse.java @@ -1,13 +1,21 @@ package likelion.MZConnent.dto.club.response; +import likelion.MZConnent.domain.club.AgeRestriction; +import likelion.MZConnent.domain.club.Club; +import likelion.MZConnent.domain.club.ClubRole; +import likelion.MZConnent.domain.club.GenderRestriction; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.extern.slf4j.Slf4j; import java.time.LocalDate; import java.time.LocalDateTime; @Getter +@Slf4j +@ToString @NoArgsConstructor public class ClubSimpleResponse { private Long clubId; @@ -19,15 +27,15 @@ public class ClubSimpleResponse { private String leaderProfileImage; private LocalDate meetingDate; private LocalDateTime createdDate; - private String genderRestriction; - private String ageRestriction; + private GenderRestriction genderRestriction; + private AgeRestriction ageRestriction; private int currentParticipant; private int maxParticipant; @Builder public ClubSimpleResponse(Long clubId, String title, Long regionId, String regionName, Long cultureCategoryId, String cultureName, String leaderProfileImage, LocalDate meetingDate, - LocalDateTime createdDate, String genderRestriction, String ageRestriction, + LocalDateTime createdDate, GenderRestriction genderRestriction, AgeRestriction ageRestriction, int currentParticipant, int maxParticipant) { this.clubId = clubId; this.title = title; @@ -43,4 +51,23 @@ public ClubSimpleResponse(Long clubId, String title, Long regionId, String regio this.currentParticipant = currentParticipant; this.maxParticipant = maxParticipant; } + + public ClubSimpleResponse(Club club) { + this.clubId = club.getClubId(); + this.title = club.getTitle(); + this.regionId = club.getRegion().getRegionId(); + this.regionName = club.getRegion().getName(); + this.cultureCategoryId = club.getCulture().getCultureId(); + this.cultureName = club.getCulture().getName(); + this.leaderProfileImage = club.getClubMembers().stream().filter(clubMember -> clubMember.getClubRole().equals(ClubRole.LEADER)).findFirst().orElseThrow(()-> { + log.info("모임장이 존재하지 않음."); + return new IllegalArgumentException("모임장이 존재하지 않습니다."); + }).getMember().getProfileImageUrl(); + this.meetingDate = club.getMeetingDate(); + this.createdDate = club.getCreatedDate(); + this.genderRestriction = club.getGenderRestriction(); + this.ageRestriction = club.getAgeRestriction(); + this.currentParticipant = club.getCurrentParticipant(); + this.maxParticipant = club.getMaxParticipant(); + } } diff --git a/src/main/java/likelion/MZConnent/dto/culture/response/CultureDetailResponse.java b/src/main/java/likelion/MZConnent/dto/culture/response/CultureDetailResponse.java index ebbb7d8..db491f6 100644 --- a/src/main/java/likelion/MZConnent/dto/culture/response/CultureDetailResponse.java +++ b/src/main/java/likelion/MZConnent/dto/culture/response/CultureDetailResponse.java @@ -5,6 +5,7 @@ import likelion.MZConnent.domain.club.ClubRole; import likelion.MZConnent.domain.club.GenderRestriction; import likelion.MZConnent.domain.culture.Culture; +import likelion.MZConnent.dto.club.response.ClubSimpleResponse; import likelion.MZConnent.dto.review.response.ReviewsSimpleResponse; import lombok.*; import lombok.extern.slf4j.Slf4j; @@ -27,7 +28,7 @@ public class CultureDetailResponse { private int interestCount; private String recommendedMember; private String content; - private List clubs; + private List clubs; private List reviews; @Builder @@ -40,51 +41,11 @@ public CultureDetailResponse(Culture culture) { this.recommendedMember = culture.getRecommendedMember(); this.content = culture.getContent(); this.clubs = culture.getClubs().stream().filter(club -> - (club.getStatus().equals("OPEN") - )).map(club -> - ClubsSimpleResponse.builder() - .club(club).build()).collect(Collectors.toList()); + (club.getStatus().equals("OPEN") + )).map(ClubSimpleResponse::new).collect(Collectors.toList()); this.reviews = culture.getReviews().stream().map( review -> ReviewsSimpleResponse.builder() .review(review).build() ).collect(Collectors.toList()); } - - - @Getter - @ToString - @NoArgsConstructor(access = AccessLevel.PROTECTED) - static private class ClubsSimpleResponse { - private Long clubId; - private String title; - private String regionName; - private String cultureName; - private String leaderProfileImage; - private LocalDate meetingDate; - private LocalDateTime createdDate; - private GenderRestriction genderRestriction; - private AgeRestriction ageRestriction; - private int currentParticipant; - private int maxParticipant; - - @Builder - public ClubsSimpleResponse(Club club) { - this.clubId = club.getClubId(); - this.title = club.getTitle(); - this.regionName = club.getRegion().getName(); - this.cultureName = club.getCulture().getName(); - this.leaderProfileImage = club.getClubMembers().stream().filter((member) -> - member.getClubRole() == ClubRole.LEADER - ).findFirst().orElseThrow(() -> { - log.info("모임장이 존재하지 않음."); - return new IllegalArgumentException("모임장이 존재하지 않습니다."); - }).getMember().getProfileImageUrl(); - this.meetingDate = club.getMeetingDate(); - this.createdDate = club.getCreatedDate(); - this.genderRestriction = club.getGenderRestriction(); - this.ageRestriction = club.getAgeRestriction(); - this.currentParticipant = club.getCurrentParticipant(); - this.maxParticipant = club.getMaxParticipant(); - } - } } diff --git a/src/main/java/likelion/MZConnent/dto/main/response/MainInfoResponse.java b/src/main/java/likelion/MZConnent/dto/main/response/MainInfoResponse.java new file mode 100644 index 0000000..4e1b106 --- /dev/null +++ b/src/main/java/likelion/MZConnent/dto/main/response/MainInfoResponse.java @@ -0,0 +1,30 @@ +package likelion.MZConnent.dto.main.response; + +import likelion.MZConnent.domain.club.Club; +import likelion.MZConnent.domain.culture.Culture; +import likelion.MZConnent.domain.review.Review; +import likelion.MZConnent.dto.club.response.ClubSimpleResponse; +import likelion.MZConnent.dto.culture.response.CulturesSimpleResponse; +import likelion.MZConnent.dto.review.response.ReviewsSimpleResponse; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.stream.Collectors; + +@Data +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class MainInfoResponse { + private List popularCultures; + private List popularReviews; + private List recentClubs; + + @Builder + public MainInfoResponse(List popularCultures, List popularReviews, List recentClubs) { + this.popularCultures = popularCultures.stream().map(culture -> CulturesSimpleResponse.builder().culture(culture).build()).collect(Collectors.toList()); + this.popularReviews = popularReviews.stream().map(review -> ReviewsSimpleResponse.builder().review(review).build()).collect(Collectors.toList()); + this.recentClubs = recentClubs.stream().map(ClubSimpleResponse::new).collect(Collectors.toList()); + } +} diff --git a/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java b/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java index b8998dc..e62b100 100644 --- a/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java +++ b/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java @@ -9,6 +9,7 @@ import org.springframework.stereotype.Repository; import java.util.Collection; +import java.util.List; @Repository public interface ClubRepository extends JpaRepository { @@ -24,5 +25,8 @@ Page findAllByFilters(@Param("cultureId") Long cultureId, Pageable pageable); Collection findAllByStatus(String status); + + @Query("SELECT c FROM Club c WHERE c.status = 'OPEN' ORDER BY c.createdDate DESC") + List findTop6OrderByCreatedDateDesc(Pageable pageable); } diff --git a/src/main/java/likelion/MZConnent/repository/culture/CultureRepository.java b/src/main/java/likelion/MZConnent/repository/culture/CultureRepository.java index 66fb886..8436830 100644 --- a/src/main/java/likelion/MZConnent/repository/culture/CultureRepository.java +++ b/src/main/java/likelion/MZConnent/repository/culture/CultureRepository.java @@ -8,6 +8,8 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface CultureRepository extends JpaRepository { @Query("SELECT c FROM Culture c WHERE :category = 0 OR c.cultureCategory.id = :category") @@ -15,4 +17,8 @@ public interface CultureRepository extends JpaRepository { @Query("SELECT c FROM Culture c JOIN c.cultureInterests ci JOIN ci.member m WHERE (:category = 0 OR c.cultureCategory.id = :category) AND m.email = :email") Page findByMemberAndCategory(@Param("email") String email, @Param("category") Long category, Pageable pageable); + + @Query("SELECT c FROM Culture c ORDER BY c.interestCount DESC") + List findTop4ByInterestCount(Pageable pageable); + } diff --git a/src/main/java/likelion/MZConnent/repository/review/ReviewRepository.java b/src/main/java/likelion/MZConnent/repository/review/ReviewRepository.java index 48d3799..0bd0384 100644 --- a/src/main/java/likelion/MZConnent/repository/review/ReviewRepository.java +++ b/src/main/java/likelion/MZConnent/repository/review/ReviewRepository.java @@ -1,6 +1,7 @@ package likelion.MZConnent.repository.review; import io.lettuce.core.dynamic.annotation.Param; +import likelion.MZConnent.domain.culture.Culture; import likelion.MZConnent.domain.review.Review; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -14,4 +15,7 @@ public interface ReviewRepository extends JpaRepository { @Query("SELECT r FROM Review r WHERE r.title LIKE %:keyword%") Page findByKeyword(@Param("keyword") String keyword, Pageable pageable); + + @Query("SELECT r FROM Review r ORDER BY r.likeCount DESC") + List findTop6ByLikeCount(Pageable pageable); } diff --git a/src/main/java/likelion/MZConnent/service/club/ClubInfoService.java b/src/main/java/likelion/MZConnent/service/club/ClubInfoService.java index cf5d7d1..2c312ee 100644 --- a/src/main/java/likelion/MZConnent/service/club/ClubInfoService.java +++ b/src/main/java/likelion/MZConnent/service/club/ClubInfoService.java @@ -103,8 +103,8 @@ public PageContentResponse getClubList(ClubSimpleRequest req .leaderProfileImage(getLeaderProfileImage(club)) .meetingDate(club.getMeetingDate()) .createdDate(club.getCreatedDate()) - .genderRestriction(club.getGenderRestriction().name()) - .ageRestriction(club.getAgeRestriction().name()) + .genderRestriction(club.getGenderRestriction()) + .ageRestriction(club.getAgeRestriction()) .currentParticipant(club.getCurrentParticipant()) .maxParticipant(club.getMaxParticipant()) .build()) diff --git a/src/main/java/likelion/MZConnent/service/main/MainInfoService.java b/src/main/java/likelion/MZConnent/service/main/MainInfoService.java new file mode 100644 index 0000000..b6d7f4d --- /dev/null +++ b/src/main/java/likelion/MZConnent/service/main/MainInfoService.java @@ -0,0 +1,41 @@ +package likelion.MZConnent.service.main; + +import likelion.MZConnent.domain.club.Club; +import likelion.MZConnent.domain.culture.Culture; +import likelion.MZConnent.domain.review.Review; +import likelion.MZConnent.dto.main.response.MainInfoResponse; +import likelion.MZConnent.repository.club.ClubRepository; +import likelion.MZConnent.repository.culture.CultureRepository; +import likelion.MZConnent.repository.review.ReviewRepository; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@RequiredArgsConstructor +@Slf4j +public class MainInfoService { + private final ReviewRepository reviewRepository; + private final CultureRepository cultureRepository; + private final ClubRepository clubRepository; + public MainInfoResponse + getMainInfo() { + Pageable top4 = PageRequest.of(0, 4); + Pageable top6 = PageRequest.of(0, 3); + + List popularCultures = cultureRepository.findTop4ByInterestCount(top4); + List popularReviews = reviewRepository.findTop6ByLikeCount(top6); + List recentClubs = clubRepository.findTop6OrderByCreatedDateDesc(top6); + + + return MainInfoResponse.builder() + .popularCultures(popularCultures) + .popularReviews(popularReviews) + .recentClubs(recentClubs) + .build(); + } +} diff --git a/src/test/java/likelion/MZConnent/service/main/MainInfoServiceTest.java b/src/test/java/likelion/MZConnent/service/main/MainInfoServiceTest.java new file mode 100644 index 0000000..9c43cd2 --- /dev/null +++ b/src/test/java/likelion/MZConnent/service/main/MainInfoServiceTest.java @@ -0,0 +1,4 @@ +import static org.junit.jupiter.api.Assertions.*; +class MainInfoServiceTest { + +} \ No newline at end of file From 4191e1edbf9400f8b47d02f22ce8f288f1f09196 Mon Sep 17 00:00:00 2001 From: chaeyoungeee Date: Thu, 1 Aug 2024 22:30:50 +0900 Subject: [PATCH 06/12] =?UTF-8?q?fix:=20=ED=94=84=EB=A1=A0=ED=8A=B8=20url?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/likelion/MZConnent/config/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/likelion/MZConnent/config/SecurityConfig.java b/src/main/java/likelion/MZConnent/config/SecurityConfig.java index 96e98e8..f3a0e87 100644 --- a/src/main/java/likelion/MZConnent/config/SecurityConfig.java +++ b/src/main/java/likelion/MZConnent/config/SecurityConfig.java @@ -86,7 +86,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws @Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration config = new CorsConfiguration(); - config.setAllowedOrigins(Arrays.asList("http://localhost:3000")); // frontend url + config.setAllowedOrigins(Arrays.asList("http://mzconnect.site")); // frontend url config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS")); config.setAllowedHeaders(Collections.singletonList("*")); config.setAllowCredentials(true); From 71fb4288bd617e32089ffb53814214fd636a7066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=B1=84=EC=98=81?= Date: Mon, 5 Aug 2024 16:19:43 +0900 Subject: [PATCH 07/12] =?UTF-8?q?fix:=20spring=20security=20permit=20url?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/likelion/MZConnent/config/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/likelion/MZConnent/config/SecurityConfig.java b/src/main/java/likelion/MZConnent/config/SecurityConfig.java index f3a0e87..573476e 100644 --- a/src/main/java/likelion/MZConnent/config/SecurityConfig.java +++ b/src/main/java/likelion/MZConnent/config/SecurityConfig.java @@ -46,7 +46,7 @@ public class SecurityConfig { private final String[] permitAllUrl = {"/error", "/api/auth/login", "/api/auth/email", "/api/auth/username", // 회원 "/api/categories/culture", "/api/cultures", "/api/cultures/**", // 문화 - "/api/reviews", // 후기 + "/api/reviews/*", // 후기 "/api/categories/region", "/api/clubs/list", "/api/main", "/swagger", "/swagger-ui.html", "/swagger-ui/**", "/api-docs", "/api-docs/**", "/v3/api-docs/**", //swagger From 10ee61f10688518bcecd54bfdad4c2b7d5335279 Mon Sep 17 00:00:00 2001 From: Chaeyoung Lim <102286483+chaeyoungeee@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:50:43 +0900 Subject: [PATCH 08/12] Update SecurityConfig.java --- src/main/java/likelion/MZConnent/config/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/likelion/MZConnent/config/SecurityConfig.java b/src/main/java/likelion/MZConnent/config/SecurityConfig.java index 573476e..f0f4c6f 100644 --- a/src/main/java/likelion/MZConnent/config/SecurityConfig.java +++ b/src/main/java/likelion/MZConnent/config/SecurityConfig.java @@ -86,7 +86,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws @Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration config = new CorsConfiguration(); - config.setAllowedOrigins(Arrays.asList("http://mzconnect.site")); // frontend url + config.setAllowedOrigins(Arrays.asList("http://mzconnect.site", "http://localhost:3000")); // frontend url config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS")); config.setAllowedHeaders(Collections.singletonList("*")); config.setAllowCredentials(true); From 8a31f27de1b35014bcd72a29bb03ad6e1855402c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=B1=84=EC=98=81?= Date: Mon, 5 Aug 2024 21:25:14 +0900 Subject: [PATCH 09/12] =?UTF-8?q?fix:=20spring=20security=20url=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 --- src/main/java/likelion/MZConnent/config/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/likelion/MZConnent/config/SecurityConfig.java b/src/main/java/likelion/MZConnent/config/SecurityConfig.java index 573476e..f43898f 100644 --- a/src/main/java/likelion/MZConnent/config/SecurityConfig.java +++ b/src/main/java/likelion/MZConnent/config/SecurityConfig.java @@ -46,7 +46,7 @@ public class SecurityConfig { private final String[] permitAllUrl = {"/error", "/api/auth/login", "/api/auth/email", "/api/auth/username", // 회원 "/api/categories/culture", "/api/cultures", "/api/cultures/**", // 문화 - "/api/reviews/*", // 후기 + "/api/reviews/**", // 후기 "/api/categories/region", "/api/clubs/list", "/api/main", "/swagger", "/swagger-ui.html", "/swagger-ui/**", "/api-docs", "/api-docs/**", "/v3/api-docs/**", //swagger From d52c10f9a937800ec6a6bfbf1e21650ffd8e366a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=B1=84=EC=98=81?= Date: Mon, 5 Aug 2024 23:56:39 +0900 Subject: [PATCH 10/12] =?UTF-8?q?style:=20=EA=B8=B0=EB=B3=B8=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/likelion/MZConnent/domain/member/Member.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/likelion/MZConnent/domain/member/Member.java b/src/main/java/likelion/MZConnent/domain/member/Member.java index ada766a..d9dc928 100644 --- a/src/main/java/likelion/MZConnent/domain/member/Member.java +++ b/src/main/java/likelion/MZConnent/domain/member/Member.java @@ -22,7 +22,7 @@ @ToString @NoArgsConstructor public class Member { - public static final String DEFAULT_PROFILE_IMAGE_URL = "https://mzconnect-bucket.s3.ap-northeast-2.amazonaws.com/default_image.jpeg"; + public static final String DEFAULT_PROFILE_IMAGE_URL = "https://mzconnect-bucket.s3.ap-northeast-2.amazonaws.com/default_image.png"; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) From 4f91ce6906225c831522e214458c693162995297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=B1=84=EC=98=81?= Date: Tue, 6 Aug 2024 00:36:01 +0900 Subject: [PATCH 11/12] =?UTF-8?q?fix:=20review=20detail=EC=9D=98=20content?= =?UTF-8?q?=20=EB=B0=98=ED=99=98=20=EB=AA=BB=ED=95=98=EB=8A=94=20=EB=B2=84?= =?UTF-8?q?=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 --- .../MZConnent/dto/review/response/ReviewDetailResponse.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java b/src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java index 24d9540..dc76807 100644 --- a/src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java +++ b/src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java @@ -37,6 +37,7 @@ public ReviewDetailResponse(Review review) { this.reviewImageUrl2 = review.getReviewImageUrl2(); this.reviewImageUrl3 = review.getReviewImageUrl3(); this.reviewImageUrl4 = review.getReviewImageUrl4(); + this.content = review.getContent(); this.createdDate = review.getCreatedDate(); this.likeCount = review.getLikeCount(); this.comments = review.getReviewComments().stream() From c2967e263406326bd3c410d19d10916a980cf36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=B1=84=EC=98=81?= Date: Tue, 6 Aug 2024 00:36:45 +0900 Subject: [PATCH 12/12] =?UTF-8?q?fix:=20review=20detail=EC=9D=98=20content?= =?UTF-8?q?=20=EB=B0=98=ED=99=98=20=EB=AA=BB=ED=95=98=EB=8A=94=20=EB=B2=84?= =?UTF-8?q?=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 --- .../MZConnent/dto/review/response/ReviewDetailResponse.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java b/src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java index dc76807..84cbcc0 100644 --- a/src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java +++ b/src/main/java/likelion/MZConnent/dto/review/response/ReviewDetailResponse.java @@ -23,6 +23,7 @@ public class ReviewDetailResponse { private String reviewImageUrl2; private String reviewImageUrl3; private String reviewImageUrl4; + private String content; private LocalDateTime createdDate; private int likeCount; private List comments = new ArrayList();