Skip to content

Commit

Permalink
Feat: 부스 목록 조회에서의 행사 필터링 기능 추가 (#277)
Browse files Browse the repository at this point in the history
* Add: 이벤트 정보를 받는 파라미터 추가

* Add: 연결된 행사 정보와 상태로 부스를 찾는 쿼리문 추가

* Feat: 행사별 부스 목록 조회 기능 추가
  • Loading branch information
muncool39 authored Oct 16, 2024
1 parent b09e540 commit 520cc00
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ public ResponseMessage registration(Authentication authentication,

@ResponseStatus(HttpStatus.OK)
@GetMapping("/booths")
public SliceResponse<BoothBasicData> getBooths(@PageableDefault(size = 6) Pageable pageable){
return SliceResponse.of(
boothService.getBooths(pageable)
.map(BoothBasicData::of)
);
public SliceResponse<BoothBasicData> getBooths(@PageableDefault(size = 6) Pageable pageable,
@RequestParam(defaultValue = "ALL") String event){
return SliceResponse.of(boothService.getBooths(pageable, event).map(BoothBasicData::of));
}

@ResponseStatus(HttpStatus.OK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public interface BoothRepository extends JpaRepository<Booth, Long> {

@Query("SELECT b FROM Booth b WHERE b.status=:boothStatus")
Slice<Booth> findAllByStatus(Pageable pageable, BoothStatus boothStatus);


Slice<Booth> findAllByLinkedEventIdAndStatus(Pageable pageable, Long eventId, BoothStatus boothStatus);

int countByLinkedEvent(Event linkedEvent);

@Query("SELECT b FROM Booth b WHERE b.name LIKE %:boothName% AND b.status =:boothStatus")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ public void boothRegistration(Long userId, BoothRegistrationRequest request){


@Transactional(readOnly = true)
public Slice<BoothDto> getBooths(Pageable pageable) {
return boothRepository.findAllByStatus(pageable, BoothStatus.APPROVE).map(booth ->
BoothDto.of(booth, boothAreaService.getBoothAreasByBoothId(booth.getId()))
);
public Slice<BoothDto> getBooths(Pageable pageable, String event) {
if(event.equals("ALL")) {
return boothRepository.findAllByStatus(pageable, BoothStatus.APPROVE).map(booth ->
BoothDto.of(booth, boothAreaService.getBoothAreasByBoothId(booth.getId()))
);
}
return boothRepository.findAllByLinkedEventIdAndStatus(pageable, Long.parseLong(event), BoothStatus.APPROVE)
.map(booth -> BoothDto.of(booth, boothAreaService.getBoothAreasByBoothId(booth.getId())));
}

@Transactional(readOnly = true)
Expand Down

0 comments on commit 520cc00

Please sign in to comment.