Skip to content

Commit

Permalink
[refactor] : meetings 전체 조회 제목 검색기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
TaetaetaE01 committed Aug 4, 2024
1 parent b6fe33c commit be32961
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ public ResponseEntity<MeetingsResponse> getMeetingsById(@PathVariable("meetingsI
@GetMapping("all/{affiliationId}")
public ResponseEntity<Page<Meetings>> 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<Meetings> meetingsPage;
Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "id"));
Page<Meetings> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@

public interface MeetingsRepository extends JpaRepository<Meetings, Long> {
Page<Meetings> findByAffiliationId(Long affiliationId, Pageable pageable);

Page<Meetings> findByAffiliationIdAndTitleContaining(Long affiliationId, String title, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ public interface MeetingsService {
MeetingsResponse getMeetingsById(Long meetingsId);

Page<Meetings> getMeetings(Long affiliationId, Pageable pageable);

Page<Meetings> searchMeetings(Long affiliationId, String title, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,11 @@ public MeetingsResponse getMeetingsById(Long meetingsId) {
public Page<Meetings> getMeetings(Long affiliationId, Pageable pageable) {
return meetingsRepository.findByAffiliationId(affiliationId, pageable);
}

@Override
@Transactional(readOnly = true)
public Page<Meetings> searchMeetings(Long affiliationId, String title, Pageable pageable) {
return meetingsRepository.findByAffiliationIdAndTitleContaining(affiliationId, title, pageable);
}

}

0 comments on commit be32961

Please sign in to comment.