diff --git a/.gitignore b/.gitignore index 0d30112..d28dd37 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,6 @@ jacoco.exec .git/ config/** + +out/ +generated/ diff --git a/finpik-api/src/main/resources/application.yml b/finpik-api/src/main/resources/application.yml index 29d9ef8..003a109 100644 --- a/finpik-api/src/main/resources/application.yml +++ b/finpik-api/src/main/resources/application.yml @@ -119,11 +119,7 @@ management: logging: level: org.springframework.security.web.authentication: debug - org.apache.kafka: error - org.apache.kafka.clients: warn - org.springframework.kafka: error - org.springframework.kafka.listener: warn - org.springframework.security: info + org.apache.kafka.clients.NetworkClient: ERROR # 필터 체인과 보안 디버깅(요청마다 어떤 필터가 적용됐는지) org.springframework.security.web.FilterChainProxy: TRACE diff --git a/finpik-infra/mysql/src/main/java/finpik/jpa/repository/loanproduct/impl/CustomRecommendedLoanProductJpaRepositoryImpl.java b/finpik-infra/mysql/src/main/java/finpik/jpa/repository/loanproduct/impl/CustomRecommendedLoanProductJpaRepositoryImpl.java index b042464..9fb69fc 100644 --- a/finpik-infra/mysql/src/main/java/finpik/jpa/repository/loanproduct/impl/CustomRecommendedLoanProductJpaRepositoryImpl.java +++ b/finpik-infra/mysql/src/main/java/finpik/jpa/repository/loanproduct/impl/CustomRecommendedLoanProductJpaRepositoryImpl.java @@ -3,6 +3,7 @@ import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; +import finpik.entity.loanproduct.RecommendedLoanProductEntity; import finpik.jpa.repository.loanproduct.CustomRecommendedLoanProductJpaRepository; import finpik.jpa.repository.loanproduct.projection.RecommendedLoanProductProjection; import finpik.util.db.OrderSpecifierTransformer; @@ -25,35 +26,39 @@ public class CustomRecommendedLoanProductJpaRepositoryImpl implements CustomReco private final JPAQueryFactory jpaQueryFactory; private static final String SIMILARITY_PROPERTY = "similarity"; - public Slice findAllByProfileId(Long productId, Pageable pageable) { - List proejctionList = jpaQueryFactory - .select(Projections.constructor(RecommendedLoanProductProjection.class, - recommendedLoanProductEntity.id, - recommendedLoanProductEntity.profileId, - loanProductEntity.bankName, - loanProductEntity.id, - loanProductEntity.productName, - loanProductEntity.maxInterestRate, - loanProductEntity.minInterestRate, - loanProductEntity.maxLoanLimitAmount, - recommendedLoanProductEntity.similarity, - recommendedLoanProductEntity.loanProductBadgeList - )) - .from(recommendedLoanProductEntity) - .where(recommendedLoanProductEntity.profileId.eq(productId)) - .leftJoin(loanProductEntity).on(recommendedLoanProductEntity.loanProductEntity.id.eq(loanProductEntity.id)) + public Slice findAllByProfileId(Long profileId, Pageable pageable) { + List recommendedLoanProducts = jpaQueryFactory + .selectFrom(recommendedLoanProductEntity) + .leftJoin(recommendedLoanProductEntity.loanProductEntity, loanProductEntity).fetchJoin() + .leftJoin(recommendedLoanProductEntity.loanProductBadgeList).fetchJoin() + .where(recommendedLoanProductEntity.profileId.eq(profileId)) + .orderBy(orderBySort(pageable.getSort())) .offset(pageable.getOffset()) .limit(getLimit(pageable.getPageSize())) - .orderBy(orderBySort(pageable.getSort())) + .distinct() .fetch(); - boolean hasNext = hasNext(proejctionList.size(), pageable.getPageSize()); - - if (hasNext) { - proejctionList.remove(pageable.getPageSize()); + boolean hasNextPage = hasNext(recommendedLoanProducts.size(), pageable.getPageSize()); + if (hasNextPage) { + recommendedLoanProducts.remove(pageable.getPageSize()); } - return new SliceImpl<>(proejctionList, pageable, hasNext); + List projections = recommendedLoanProducts.stream() + .map(entity -> new RecommendedLoanProductProjection( + entity.getId(), + entity.getProfileId(), + entity.getLoanProductEntity().getBankName(), + entity.getLoanProductEntity().getId(), + entity.getLoanProductEntity().getProductName(), + entity.getLoanProductEntity().getMinInterestRate(), + entity.getLoanProductEntity().getMaxInterestRate(), + entity.getLoanProductEntity().getMaxLoanLimitAmount(), + entity.getSimilarity(), + entity.getLoanProductBadgeList() + )) + .toList(); + + return new SliceImpl<>(projections, pageable, hasNextPage); } private OrderSpecifier[] orderBySort(Sort sort) { diff --git a/finpik-infra/mysql/src/test/java/entity/profile/ProfileEntityTest.java b/finpik-infra/mysql/src/test/java/entity/profile/ProfileEntityTest.java index 9e6043b..f724ea9 100644 --- a/finpik-infra/mysql/src/test/java/entity/profile/ProfileEntityTest.java +++ b/finpik-infra/mysql/src/test/java/entity/profile/ProfileEntityTest.java @@ -78,7 +78,7 @@ private Profile getDefaultProfile() { null, user, 0, - 0.0, + 0.0f, LocalDateTime.now(), LocalDateTime.now() );