Skip to content

Commit

Permalink
Merge pull request #188 from nhnacademy-be5-T3Team/feature/elastic
Browse files Browse the repository at this point in the history
Feature/elastic
  • Loading branch information
parkjonggyeong18 authored May 16, 2024
2 parents 734ecbc + 7466f4d commit d70be29
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Objects;

@RestController
@RequiredArgsConstructor
Expand Down Expand Up @@ -48,7 +49,12 @@ public ResponseEntity<BaseResponse<PageResponse<ElasticResponse>>> getSearchPage
return ResponseEntity.badRequest().body(new BaseResponse<>());
}

Pageable pageable = PageRequest.of(pageNo, pageSize, Sort.by(sortBy));
Pageable pageable;
if(Objects.equals(sortBy, "discounted_price")){
pageable = PageRequest.of(pageNo, pageSize, Sort.by(sortBy));
}else{
pageable = PageRequest.of(pageNo, pageSize, Sort.by(sortBy).descending());
}
PageResponse<ElasticResponse> searchList = elasticService.search(query, searchType, pageable);

BaseResponse<PageResponse<ElasticResponse>> responseBody = new BaseResponse<>();
Expand Down Expand Up @@ -81,7 +87,13 @@ public ResponseEntity<BaseResponse<PageResponse<ElasticResponse>>> getCategorySe
return ResponseEntity.badRequest().body(new BaseResponse<>());
}

Pageable pageable = PageRequest.of(pageNo, pageSize, Sort.by(sortBy));
Pageable pageable;
if(Objects.equals(sortBy, "discounted_price")){
pageable = PageRequest.of(pageNo, pageSize, Sort.by(sortBy));
}else{
pageable = PageRequest.of(pageNo, pageSize, Sort.by(sortBy).descending());
}

PageResponse<ElasticResponse> searchList =
elasticCategoryService.search(query, searchType, categoryId, pageable);

Expand Down

0 comments on commit d70be29

Please sign in to comment.