From 5b3a4f6c14539424bb63b65d800ad4e1c2517170 Mon Sep 17 00:00:00 2001 From: oosedus Date: Sat, 3 Aug 2024 02:43:07 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20club=20simple=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=20requestParam=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MZConnent/api/club/ClubController.java | 7 +++---- .../dto/club/request/ClubSimpleRequest.java | 19 ------------------- .../service/club/ClubInfoService.java | 7 +++---- 3 files changed, 6 insertions(+), 27 deletions(-) delete mode 100644 src/main/java/likelion/MZConnent/dto/club/request/ClubSimpleRequest.java diff --git a/src/main/java/likelion/MZConnent/api/club/ClubController.java b/src/main/java/likelion/MZConnent/api/club/ClubController.java index 5920c2a..35a087d 100644 --- a/src/main/java/likelion/MZConnent/api/club/ClubController.java +++ b/src/main/java/likelion/MZConnent/api/club/ClubController.java @@ -1,9 +1,7 @@ package likelion.MZConnent.api.club; -import jakarta.transaction.Transactional; import jakarta.validation.Valid; import likelion.MZConnent.domain.member.Member; -import likelion.MZConnent.dto.club.request.ClubSimpleRequest; import likelion.MZConnent.dto.club.request.CreateClubRequest; import likelion.MZConnent.dto.club.response.*; import likelion.MZConnent.jwt.principle.UserPrinciple; @@ -80,7 +78,8 @@ public ResponseEntity getClubDetail(@PathVariable Long clubI public ResponseEntity> getClubList( @RequestParam(value = "page", defaultValue = "0") int pageNumber, @RequestParam(value = "sort", defaultValue = "createdDate") String sortWay, - @RequestBody ClubSimpleRequest request) { + @RequestParam(value = "categoryId", defaultValue = "0") int categoryId, + @RequestParam(value = "regionId", defaultValue = "0") int regionId) { Pageable pageable; if(sortWay.equals("meetingDate")){ @@ -90,7 +89,7 @@ public ResponseEntity> getClubList( pageable = PageRequest.of(pageNumber, 6, Sort.by(sortWay).descending()); } - PageContentResponse clubList = clubInfoService.getClubList(request, pageable); + PageContentResponse clubList = clubInfoService.getClubList(categoryId, regionId, pageable); return ResponseEntity.ok(clubList); } } diff --git a/src/main/java/likelion/MZConnent/dto/club/request/ClubSimpleRequest.java b/src/main/java/likelion/MZConnent/dto/club/request/ClubSimpleRequest.java deleted file mode 100644 index aba263a..0000000 --- a/src/main/java/likelion/MZConnent/dto/club/request/ClubSimpleRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -package likelion.MZConnent.dto.club.request; - -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class ClubSimpleRequest { - private Long cultureId; - private Long regionId; - - @Builder - public ClubSimpleRequest(Long cultureId, Long regionId) { - this.cultureId = cultureId; - this.regionId = regionId; - } -} diff --git a/src/main/java/likelion/MZConnent/service/club/ClubInfoService.java b/src/main/java/likelion/MZConnent/service/club/ClubInfoService.java index cf5d7d1..100bd5c 100644 --- a/src/main/java/likelion/MZConnent/service/club/ClubInfoService.java +++ b/src/main/java/likelion/MZConnent/service/club/ClubInfoService.java @@ -5,7 +5,6 @@ import likelion.MZConnent.domain.member.Member; import likelion.MZConnent.dto.club.LeaderDto; import likelion.MZConnent.dto.club.SelfIntroductionDto; -import likelion.MZConnent.dto.club.request.ClubSimpleRequest; import likelion.MZConnent.dto.club.response.ClubDetailResponse; import likelion.MZConnent.dto.club.response.ClubSimpleResponse; import likelion.MZConnent.dto.club.response.PageContentResponse; @@ -85,10 +84,10 @@ private ClubDetailResponse buildClubDetailResponse(Long clubId, Member member) { .build(); } - public PageContentResponse getClubList(ClubSimpleRequest request, Pageable pageable) { + public PageContentResponse getClubList(long categoryId, long regionId, Pageable pageable) { Page clubs = clubRepository.findAllByFilters( - request.getCultureId(), - request.getRegionId(), + categoryId, + regionId, pageable); return new PageContentResponse<>( From adac58b77450bd945fdf247eb2a46d3ad185c380 Mon Sep 17 00:00:00 2001 From: oosedus Date: Sat, 3 Aug 2024 03:18:50 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20club-simple=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=ED=95=89=ED=84=B0=EB=A7=81=20=EC=95=88=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MZConnent/api/club/ClubController.java | 11 +++++------ .../repository/club/ClubRepository.java | 19 ++++++++++++++++--- .../service/club/ClubInfoService.java | 4 ++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/main/java/likelion/MZConnent/api/club/ClubController.java b/src/main/java/likelion/MZConnent/api/club/ClubController.java index 35a087d..2da6977 100644 --- a/src/main/java/likelion/MZConnent/api/club/ClubController.java +++ b/src/main/java/likelion/MZConnent/api/club/ClubController.java @@ -78,18 +78,17 @@ public ResponseEntity getClubDetail(@PathVariable Long clubI public ResponseEntity> getClubList( @RequestParam(value = "page", defaultValue = "0") int pageNumber, @RequestParam(value = "sort", defaultValue = "createdDate") String sortWay, - @RequestParam(value = "categoryId", defaultValue = "0") int categoryId, - @RequestParam(value = "regionId", defaultValue = "0") int regionId) { + @RequestParam(value = "cultureCategoryId", required = false, defaultValue = "0") long cultureCategoryId, + @RequestParam(value = "regionId", required = false, defaultValue = "0") long regionId) { Pageable pageable; - if(sortWay.equals("meetingDate")){ + if (sortWay.equals("meetingDate")) { pageable = PageRequest.of(pageNumber, 6, Sort.by(sortWay).ascending()); - } - else { + } else { pageable = PageRequest.of(pageNumber, 6, Sort.by(sortWay).descending()); } - PageContentResponse clubList = clubInfoService.getClubList(categoryId, regionId, pageable); + PageContentResponse clubList = clubInfoService.getClubList(cultureCategoryId, regionId, pageable); return ResponseEntity.ok(clubList); } } diff --git a/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java b/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java index b8998dc..dd3b250 100644 --- a/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java +++ b/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java @@ -16,10 +16,23 @@ public interface ClubRepository extends JpaRepository { // status가 OPEN인 클럽만 조회 // cultureId와 regionId가 0이면 무시 // cultureId와 regionId가 0이 아니면 해당 cultureId와 regionId에 맞는 클럽만 조회 - @Query("SELECT c FROM Club c WHERE c.status = 'OPEN' " + - "AND (:cultureId = 0 OR c.culture.cultureId = :cultureId) " + +// @Query("SELECT c FROM Club c WHERE c.status = 'OPEN' " + +// "AND (:cultureId = 0 OR c.culture.cultureId = :cultureId) " + +// "AND (:regionId = 0 OR c.region.regionId = :regionId)") +// Page findAllByFilters(@Param("cultureId") Long cultureId, +// @Param("regionId") Long regionId, +// Pageable pageable); + + // status가 OPEN인 클럽만 조회 + // cultureCategoryId와 regionId가 0이면 무시 + // cultureCategoryId와 regionId가 0이 아니면 해당 cultureCategoryId와 regionId에 맞는 클럽만 조회 + @Query("SELECT c FROM Club c " + + "JOIN c.culture cu " + + "JOIN cu.cultureCategory cc " + + "WHERE c.status = 'OPEN' " + + "AND (:cultureCategoryId = 0 OR cc.id = :cultureCategoryId) " + "AND (:regionId = 0 OR c.region.regionId = :regionId)") - Page findAllByFilters(@Param("cultureId") Long cultureId, + Page findAllByFilters(@Param("cultureCategoryId") Long cultureCategoryId, @Param("regionId") Long regionId, 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 100bd5c..39abe0e 100644 --- a/src/main/java/likelion/MZConnent/service/club/ClubInfoService.java +++ b/src/main/java/likelion/MZConnent/service/club/ClubInfoService.java @@ -84,9 +84,9 @@ private ClubDetailResponse buildClubDetailResponse(Long clubId, Member member) { .build(); } - public PageContentResponse getClubList(long categoryId, long regionId, Pageable pageable) { + public PageContentResponse getClubList(long cultureCategoryId, long regionId, Pageable pageable) { Page clubs = clubRepository.findAllByFilters( - categoryId, + cultureCategoryId, regionId, pageable); From e48454e517368c5a48971353eeece2936a159a03 Mon Sep 17 00:00:00 2001 From: oosedus Date: Sat, 3 Aug 2024 03:20:18 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MZConnent/repository/club/ClubRepository.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java b/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java index dd3b250..354fa72 100644 --- a/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java +++ b/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java @@ -13,16 +13,6 @@ @Repository public interface ClubRepository extends JpaRepository { - // status가 OPEN인 클럽만 조회 - // cultureId와 regionId가 0이면 무시 - // cultureId와 regionId가 0이 아니면 해당 cultureId와 regionId에 맞는 클럽만 조회 -// @Query("SELECT c FROM Club c WHERE c.status = 'OPEN' " + -// "AND (:cultureId = 0 OR c.culture.cultureId = :cultureId) " + -// "AND (:regionId = 0 OR c.region.regionId = :regionId)") -// Page findAllByFilters(@Param("cultureId") Long cultureId, -// @Param("regionId") Long regionId, -// Pageable pageable); - // status가 OPEN인 클럽만 조회 // cultureCategoryId와 regionId가 0이면 무시 // cultureCategoryId와 regionId가 0이 아니면 해당 cultureCategoryId와 regionId에 맞는 클럽만 조회