diff --git a/src/main/java/likelion/MZConnent/api/club/ClubController.java b/src/main/java/likelion/MZConnent/api/club/ClubController.java index 5920c2a..2da6977 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,17 +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, - @RequestBody ClubSimpleRequest request) { + @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(request, pageable); + PageContentResponse clubList = clubInfoService.getClubList(cultureCategoryId, 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/repository/club/ClubRepository.java b/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java index b8998dc..354fa72 100644 --- a/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java +++ b/src/main/java/likelion/MZConnent/repository/club/ClubRepository.java @@ -14,12 +14,15 @@ 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) " + + // 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 cf5d7d1..39abe0e 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 cultureCategoryId, long regionId, Pageable pageable) { Page clubs = clubRepository.findAllByFilters( - request.getCultureId(), - request.getRegionId(), + cultureCategoryId, + regionId, pageable); return new PageContentResponse<>(