SortUtil 사용법에 대해... #65
YeaChan05
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
정렬을 위해
Pageable객체를 통해 요청이 들어오면 매번 pageable 객체를 통해 orderSpecifier를 지정해주는 과정이 반복될 것이 예상되어 하나의 Util 클래스를 작성했습니다정렬을 사용하는 구현체인 경우
SortableRepository의getOrderSpecifiers를 구현해 정렬 조건을 주입할 함수를 구현해줍니다getOrderSpecifiers를 사용하실때from메서드를 사용하면pageable객체 내부로 들어가 정렬조건 문자열이 열거체에 등록되어있는ComparableExpressionBase기준으로 정렬됩니다. Qclass의 숫자나 문자등의 필드에 대해 정렬을 가능케 합니다.필요한 정렬 기준은 열거체에 넣어주시면
from이 동작할때 정렬 조건으로 추가됩니다.디자인패턴에 대한 개념이 약한편이라 해당 방식이 좋은 방법인지에 대해서는 잘 모르겠네요 ㅎㅎ.. 그래도 나름 공통된 부분을 분리하려 노력해봤습니다
더 좋은 방법 있으시면 코멘트 부탁드립니다
Beta Was this translation helpful? Give feedback.
All reactions