Skip to content

Commit

Permalink
fix: remove sort in search endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
BettyB979 committed Dec 6, 2024
1 parent 98d36d5 commit 005a4a6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,12 @@ public Page<SearchContactDto> searchContacts(
@RequestParam(required = true) String searchParam,
@RequestParam(required = false) @Valid @ValidContactParam String searchType,
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "identifier") String sort) {
@RequestParam(defaultValue = "10") Integer pageSize) {

log.info(
"Search contact by {} with param = {} page = {} pageSize = {}", searchType, searchParam, page, pageSize);

Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
Pageable pageable = PageRequest.of(page, pageSize);

switch (ContactParamEnum.fromValue(searchType)) {
case ContactParamEnum.IDENTIFIER:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ public Page<SearchSurveyUnitDto> searchSurveyUnits(
@RequestParam(required = true) String searchParam,
@RequestParam(required = true) @Valid @ValidSurveyUnitParam @Schema(description = "id or code or name")String searchType,
@RequestParam(defaultValue = "0") Integer page,
@RequestParam(defaultValue = "20") Integer pageSize,
@RequestParam(defaultValue = "id_su") String sort) {
@RequestParam(defaultValue = "20") Integer pageSize) {
log.info(
"Search surveyUnit by {} with param = {} page = {} pageSize = {}", searchType, searchParam, page, pageSize);

Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
Pageable pageable = PageRequest.of(page, pageSize);

return switch (SurveyUnitParamEnum.fromValue(searchType)) {
case SurveyUnitParamEnum.IDENTIFIER -> surveyUnitService.findbyIdentifier(searchParam, pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class SurveyUnit {
private String label;


@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private SurveyUnitAddress surveyUnitAddress;

@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "surveyUnit" )
Expand Down

0 comments on commit 005a4a6

Please sign in to comment.