diff --git a/src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsController.java b/src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsController.java index c3d6df2..fa9290a 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsController.java +++ b/src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsController.java @@ -55,9 +55,15 @@ public ResponseEntity getMeetingsById(@PathVariable("meetingsI @GetMapping("all/{affiliationId}") public ResponseEntity> getMeetingsList(@PathVariable("affiliationId") Long affiliationId, @RequestParam(name = "page", defaultValue = "0") int page, - @RequestParam(name = "size", defaultValue = "10") int size) { + @RequestParam(name = "size", defaultValue = "10") int size, + @RequestParam(name = "search", required = false) String search) { + Page meetingsPage; Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "id")); - Page meetingsPage = meetingsService.getMeetings(affiliationId, pageable); + if (search != null && !search.isEmpty()) { + meetingsPage = meetingsService.searchMeetings(affiliationId, search, pageable); + } else { + meetingsPage = meetingsService.getMeetings(affiliationId, pageable); + } return ResponseEntity.ok().body(meetingsPage); } } diff --git a/src/main/java/com/example/bigbrotherbe/domain/meetings/repository/MeetingsRepository.java b/src/main/java/com/example/bigbrotherbe/domain/meetings/repository/MeetingsRepository.java index c01f7a2..dd0813c 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/meetings/repository/MeetingsRepository.java +++ b/src/main/java/com/example/bigbrotherbe/domain/meetings/repository/MeetingsRepository.java @@ -7,4 +7,6 @@ public interface MeetingsRepository extends JpaRepository { Page findByAffiliationId(Long affiliationId, Pageable pageable); + + Page findByAffiliationIdAndTitleContaining(Long affiliationId, String title, Pageable pageable); } diff --git a/src/main/java/com/example/bigbrotherbe/domain/meetings/service/MeetingsService.java b/src/main/java/com/example/bigbrotherbe/domain/meetings/service/MeetingsService.java index 838e208..38e2c8b 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/meetings/service/MeetingsService.java +++ b/src/main/java/com/example/bigbrotherbe/domain/meetings/service/MeetingsService.java @@ -20,4 +20,6 @@ public interface MeetingsService { MeetingsResponse getMeetingsById(Long meetingsId); Page getMeetings(Long affiliationId, Pageable pageable); + + Page searchMeetings(Long affiliationId, String title, Pageable pageable); } diff --git a/src/main/java/com/example/bigbrotherbe/domain/meetings/service/MeetingsServiceImpl.java b/src/main/java/com/example/bigbrotherbe/domain/meetings/service/MeetingsServiceImpl.java index 3cbd369..a608106 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/meetings/service/MeetingsServiceImpl.java +++ b/src/main/java/com/example/bigbrotherbe/domain/meetings/service/MeetingsServiceImpl.java @@ -122,4 +122,11 @@ public MeetingsResponse getMeetingsById(Long meetingsId) { public Page getMeetings(Long affiliationId, Pageable pageable) { return meetingsRepository.findByAffiliationId(affiliationId, pageable); } + + @Override + @Transactional(readOnly = true) + public Page searchMeetings(Long affiliationId, String title, Pageable pageable) { + return meetingsRepository.findByAffiliationIdAndTitleContaining(affiliationId, title, pageable); + } + }