Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

허용된 Sorting 방식을 정해야 합니다. #299

Open
wannte opened this issue Mar 12, 2022 · 0 comments
Open

허용된 Sorting 방식을 정해야 합니다. #299

wannte opened this issue Mar 12, 2022 · 0 comments

Comments

@wannte
Copy link
Contributor

wannte commented Mar 12, 2022

현재 petition의 모든 값으로 sorting을 진행할 수 있습니다.

private OrderSpecifier[] orderCondition(Pageable pageable) {
        PathBuilder<Petition> entityPath = new PathBuilder<>(Petition.class, "petition");
        return pageable.getSort()
                .stream()
                .map(order -> getOrderSpecifier(entityPath, order))
                .toArray(OrderSpecifier[]::new);
}

private OrderSpecifier getOrderSpecifier(PathBuilder<Petition> entityPath, Sort.Order order) {
        if ("agreeCount".equals(order.getProperty())) {
            return new OrderSpecifier(Order.valueOf(order.getDirection().name()), agreeCount.count);
        }
        return new OrderSpecifier(Order.valueOf(order.getDirection().name()), entityPath.get(order.getProperty()));
}

기존에는 petition에서 column으로 접근을 진행했지만, agreeCount 조회를 위해서는 하드 코딩으로 해결했습니다.
이 부분에 대한 정리도 필요합니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant