Skip to content

Commit

Permalink
Merge pull request #102 from PLADI-ALM/fix/PDS-91-Asc-Decs
Browse files Browse the repository at this point in the history
[PDS-91/fix] 오름차순, 내림차순 정렬
  • Loading branch information
leeseunghakhello authored Oct 18, 2023
2 parents 14fbb92 + 9f7966c commit 30dd089
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ public ResponseCustom returnBookingResource(
@GetMapping("/resources")
public ResponseCustom<Page<AdminResourceRes>> getBookingResources(
@Account User user,
@Parameter(description = "(Boolean) 오름차순/내림차순", example = "true / false") boolean active,
@PageableDefault(size = 8) Pageable pageable){
return ResponseCustom.OK(bookingService.getBookingResources(user,pageable));
return ResponseCustom.OK(bookingService.getBookingResources(user,pageable,active));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,17 @@ public void returnBookingResourceByAdmin(User user, Long resourceBookingId) {
/**
* 관리자 자원 예약 목록을 조회
*/
public Page<AdminResourceRes> getBookingResources(User user,Pageable pageable) {
public <active> Page<AdminResourceRes> getBookingResources(User user, Pageable pageable,boolean active) {
checkAdminRole(user);
Pageable sortedByDateAsc = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(),
Sort.by(Sort.Order.asc("startDate")));

Sort.Order order = active ? Sort.Order.asc("startDate") : Sort.Order.desc("startDate");

Pageable sortedByDate = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(),
Sort.by(order));

Page<ResourceBooking> resourceBookings=resourceBookingRepository.findByStatusIn(
Arrays.asList(BookingStatus.BOOKED, BookingStatus.USING,BookingStatus.WAITING),
sortedByDateAsc
sortedByDate
);

return resourceBookings.map(AdminResourceRes::toDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public AdminResourcesDetailsRes getAdminResourcesDetails(User user, Long resourc
Resource resource = resourceRepository.findById(resourceId)
.orElseThrow(() ->new BaseException(BaseResponseCode.RESOURCE_NOT_FOUND));

List<ResourceBooking> resourceBookings = resourceBookingRepository.findAllByResourceOrderByStartDateDesc(resource);
List<ResourceBooking> resourceBookings=resourceBookingRepository.findAllByResourceOrderByStartDateDesc(resource);

List<ResourcesList> resourcesLists = resourceBookings.stream()
.map(ResourcesList::toDto)
Expand Down

0 comments on commit 30dd089

Please sign in to comment.