From 6243e417ed0b17e4be05ee9c60f4730493eb8517 Mon Sep 17 00:00:00 2001 From: yang Date: Wed, 3 Jul 2024 02:35:17 +0900 Subject: [PATCH] =?UTF-8?q?RAC-403=20fix=20:=20=EC=84=A0=EB=B0=B0=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EC=8B=9C=20=EB=A9=98=ED=86=A0=EB=A7=81=20?= =?UTF-8?q?=ED=9A=9F=EC=88=98=20=EC=A0=95=EB=A0=AC=20=EC=9A=B0=EC=84=A0?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/SeniorDslRepositoryImpl.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepositoryImpl.java b/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepositoryImpl.java index 505ecb8f..6c303f97 100644 --- a/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepositoryImpl.java +++ b/src/main/java/com/postgraduate/domain/senior/domain/repository/SeniorDslRepositoryImpl.java @@ -37,7 +37,7 @@ public class SeniorDslRepositoryImpl implements SeniorDslRepository{ @Override public Page findAllBySearchSenior(String search, String sort, Pageable pageable) { - List results = queryFactory.select(senior.seniorId, senior.user.nickName, senior.hit) + List results = queryFactory.select(senior.seniorId, senior.user.nickName, senior.hit, senior.mentoringHit) .from(senior) .distinct() .leftJoin(senior.user, user) @@ -46,7 +46,8 @@ public Page findAllBySearchSenior(String search, String sort, Pageable p .or(senior.user.nickName.like("%" + search + "%")), senior.user.isDelete.eq(FALSE) ) - .orderBy(orderSpecifier(sort)) + .orderBy(mentoringOrderSpecifier(sort)) + .orderBy(hitOrderSpecifier(sort)) .orderBy(senior.user.nickName.asc()) .offset(pageable.getOffset()) .limit(pageable.getPageSize()) @@ -62,7 +63,8 @@ public Page findAllBySearchSenior(String search, String sort, Pageable p .toList())) .leftJoin(senior.user, user) .fetchJoin() - .orderBy(orderSpecifier(sort)) + .orderBy(mentoringOrderSpecifier(sort)) + .orderBy(hitOrderSpecifier(sort)) .orderBy(senior.user.nickName.asc()) .fetch(); @@ -81,7 +83,7 @@ public Page findAllBySearchSenior(String search, String sort, Pageable p return new PageImpl<>(seniors, pageable, total); } - private OrderSpecifier orderSpecifier(String sort) { + private OrderSpecifier hitOrderSpecifier(String sort) { if (sort == null) return new OrderSpecifier<>(DESC, senior.hit); if (sort.equals("low")) @@ -89,9 +91,18 @@ private OrderSpecifier orderSpecifier(String sort) { return new OrderSpecifier<>(DESC, senior.hit); } + private OrderSpecifier mentoringOrderSpecifier(String sort) { + if (sort == null) + return new OrderSpecifier<>(DESC, senior.mentoringHit); + if (sort.equals("low")) + return new OrderSpecifier<>(ASC, senior.mentoringHit); + return new OrderSpecifier<>(DESC, senior.mentoringHit); + } + + @Override public Page findAllByFieldSenior(String field, String postgradu, Pageable pageable) { - List results = queryFactory.select(senior.seniorId, senior.user.nickName, senior.hit) + List results = queryFactory.select(senior.seniorId, senior.user.nickName, senior.hit, senior.mentoringHit) .from(senior) .distinct() .leftJoin(senior.user, user) @@ -100,6 +111,7 @@ public Page findAllByFieldSenior(String field, String postgradu, Pageabl postgraduSpecifier(postgradu), senior.user.isDelete.eq(FALSE) ) + .orderBy(senior.mentoringHit.desc()) .orderBy(senior.hit.desc()) .orderBy(senior.user.nickName.asc()) .offset(pageable.getOffset()) @@ -116,6 +128,7 @@ public Page findAllByFieldSenior(String field, String postgradu, Pageabl .toList())) .leftJoin(senior.user, user) .fetchJoin() + .orderBy(senior.mentoringHit.desc()) .orderBy(senior.hit.desc()) .orderBy(senior.user.nickName.asc()) .fetch();