Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ jacoco.exec
.git/

config/**

out/
generated/
6 changes: 1 addition & 5 deletions finpik-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,35 +26,39 @@ public class CustomRecommendedLoanProductJpaRepositoryImpl implements CustomReco
private final JPAQueryFactory jpaQueryFactory;
private static final String SIMILARITY_PROPERTY = "similarity";

public Slice<RecommendedLoanProductProjection> findAllByProfileId(Long productId, Pageable pageable) {
List<RecommendedLoanProductProjection> 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<RecommendedLoanProductProjection> findAllByProfileId(Long profileId, Pageable pageable) {
List<RecommendedLoanProductEntity> 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<RecommendedLoanProductProjection> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private Profile getDefaultProfile() {
null,
user,
0,
0.0,
0.0f,
LocalDateTime.now(),
LocalDateTime.now()
);
Expand Down