From be708b4c0a9cb2fd493e9ef7bae0066549c79b63 Mon Sep 17 00:00:00 2001 From: Hong Jeong Hyeon Date: Wed, 5 May 2021 13:51:23 +0900 Subject: [PATCH] [UPDATE] repository --- .../repository/ReportCustomRepositoryImpl.java | 13 +++++-------- .../entity/report/repository/ReportRepository.java | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/dsmpear/main/user_backend_v2/entity/report/repository/ReportCustomRepositoryImpl.java b/src/main/java/com/dsmpear/main/user_backend_v2/entity/report/repository/ReportCustomRepositoryImpl.java index 4bc2cad..7be54aa 100644 --- a/src/main/java/com/dsmpear/main/user_backend_v2/entity/report/repository/ReportCustomRepositoryImpl.java +++ b/src/main/java/com/dsmpear/main/user_backend_v2/entity/report/repository/ReportCustomRepositoryImpl.java @@ -31,7 +31,7 @@ public Page findAllByAccessAndGradeAndFieldAndType(Grade grade, Field fi .and(report.isAccepted.eq(true))) .where(eqGrade(grade) .and(eqType(type)) - .and(eqAccess(Access.EVERY)) + .and(eqAccess()) .and(eqField(field))) .offset(pageable.getOffset()) .limit(pageable.getPageSize()) @@ -41,14 +41,14 @@ public Page findAllByAccessAndGradeAndFieldAndType(Grade grade, Field fi return new PageImpl<>(results.getResults(), pageable, results.getTotal()); } - public Page findAllByMembersContainsAndIsAcceptedAndIsSubmittedTrueAndReportTypeAccessOrderByReportIdDesc(User user, Access access, Pageable page) { + public Page findAllByMembersContainsAndIsAcceptedAndIsSubmittedTrueAndReportTypeAccessOrderByReportIdDesc(User user, Pageable page) { QueryResults results = jpaQueryFactory .select(report) .from(report) .where(report.members.any().user.eq(user) .and(report.isAccepted.eq(true)) .and(report.isSubmitted.eq(true)) - .and(report.reportType.access.eq(access))) + .and(eqAccess())) .offset(page.getOffset()) .limit(page.getPageSize()) .orderBy(report.id.desc()) @@ -57,11 +57,8 @@ public Page findAllByMembersContainsAndIsAcceptedAndIsSubmittedTrueAndRe return new PageImpl<>(results.getResults(), page, results.getTotal()); } - private BooleanExpression eqAccess(Access access) { - if (access == null) { - return null; - } - return report.reportType.access.eq(access); + private BooleanExpression eqAccess() { + return report.reportType.access.eq(Access.EVERY); } private BooleanExpression eqGrade(Grade grade) { diff --git a/src/main/java/com/dsmpear/main/user_backend_v2/entity/report/repository/ReportRepository.java b/src/main/java/com/dsmpear/main/user_backend_v2/entity/report/repository/ReportRepository.java index 633a130..58d57c8 100644 --- a/src/main/java/com/dsmpear/main/user_backend_v2/entity/report/repository/ReportRepository.java +++ b/src/main/java/com/dsmpear/main/user_backend_v2/entity/report/repository/ReportRepository.java @@ -1,5 +1,6 @@ -package com.dsmpear.main.user_backend_v2.entity.report; +package com.dsmpear.main.user_backend_v2.entity.report.repository; +import com.dsmpear.main.user_backend_v2.entity.report.Report; import com.dsmpear.main.user_backend_v2.entity.report.enums.Access; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -8,7 +9,6 @@ import java.util.Optional; - @Repository public interface ReportRepository extends CrudRepository { // 보고서 갖고오기