Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: club simple 조회 requestParam 수정 #77

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/main/java/likelion/MZConnent/api/club/ClubController.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -80,17 +78,17 @@ public ResponseEntity<ClubDetailResponse> getClubDetail(@PathVariable Long clubI
public ResponseEntity<PageContentResponse<ClubSimpleResponse>> 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<ClubSimpleResponse> clubList = clubInfoService.getClubList(request, pageable);
PageContentResponse<ClubSimpleResponse> clubList = clubInfoService.getClubList(cultureCategoryId, regionId, pageable);
return ResponseEntity.ok(clubList);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
public interface ClubRepository extends JpaRepository<Club, Long> {

// 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<Club> findAllByFilters(@Param("cultureId") Long cultureId,
Page<Club> findAllByFilters(@Param("cultureCategoryId") Long cultureCategoryId,
@Param("regionId") Long regionId,
Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,10 +84,10 @@ private ClubDetailResponse buildClubDetailResponse(Long clubId, Member member) {
.build();
}

public PageContentResponse<ClubSimpleResponse> getClubList(ClubSimpleRequest request, Pageable pageable) {
public PageContentResponse<ClubSimpleResponse> getClubList(long cultureCategoryId, long regionId, Pageable pageable) {
Page<Club> clubs = clubRepository.findAllByFilters(
request.getCultureId(),
request.getRegionId(),
cultureCategoryId,
regionId,
pageable);

return new PageContentResponse<>(
Expand Down
Loading