From c6115ca38513eb9492b3b014419bcd0ba465f832 Mon Sep 17 00:00:00 2001 From: skytin1004 Date: Fri, 16 Feb 2024 09:20:58 +0900 Subject: [PATCH] =?UTF-8?q?[feature/Inhabas#228]=20=EA=B3=B5=EB=AA=A8?= =?UTF-8?q?=EC=A0=84=20=EA=B2=8C=EC=8B=9C=ED=8C=90=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContestBoardRepositoryImpl.java | 19 ++++++------------- .../usecase/ContestBoardServiceImpl.java | 3 +-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java index 1a2fc733..d4174cec 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/contest/repository/ContestBoardRepositoryImpl.java @@ -1,20 +1,18 @@ package com.inhabas.api.domain.contest.repository; -import static com.inhabas.api.domain.contest.domain.QContestBoard.contestBoard; - +import com.inhabas.api.domain.contest.domain.QContestBoard; import java.util.ArrayList; import java.util.HashMap; import java.util.List; + import java.util.Map; import java.util.function.BiFunction; - import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import com.inhabas.api.domain.contest.domain.ContestBoard; -import com.inhabas.api.domain.contest.domain.QContestBoard; import com.inhabas.api.domain.contest.domain.valueObject.ContestType; import com.querydsl.core.types.Order; import com.querydsl.core.types.OrderSpecifier; @@ -29,16 +27,12 @@ public class ContestBoardRepositoryImpl implements ContestBoardRepositoryCustom private QContestBoard contestBoard = QContestBoard.contestBoard; // 필드 이름과 정렬 기준을 매핑 - private OrderSpecifier getSortedColumn( - Order order, QContestBoard contestBoard, String fieldName) { - Map>> orderSpecifierMap = - new HashMap<>(); + private OrderSpecifier getSortedColumn(Order order, QContestBoard contestBoard, String fieldName) { + Map>> orderSpecifierMap = new HashMap<>(); orderSpecifierMap.put("id", (o, cb) -> new OrderSpecifier<>(o, cb.id)); orderSpecifierMap.put("dateContestEnd", (o, cb) -> new OrderSpecifier<>(o, cb.dateContestEnd)); - return orderSpecifierMap - .getOrDefault(fieldName, (o, cb) -> new OrderSpecifier<>(Order.DESC, cb.dateContestEnd)) - .apply(order, contestBoard); + return orderSpecifierMap.getOrDefault(fieldName, (o, cb) -> new OrderSpecifier<>(Order.DESC, cb.dateContestEnd)).apply(order, contestBoard); } // 페이지 요청에 따른 정렬 @@ -47,8 +41,7 @@ public List> getAllOrderSpecifiers(Pageable pageable) { if (pageable.getSort() != null) { for (Sort.Order order : pageable.getSort()) { Order direction = order.getDirection().isAscending() ? Order.ASC : Order.DESC; - OrderSpecifier orderSpecifier = - getSortedColumn(direction, contestBoard, order.getProperty()); + OrderSpecifier orderSpecifier = getSortedColumn(direction, contestBoard, order.getProperty()); orders.add(orderSpecifier); } } else { diff --git a/resource-server/src/main/java/com/inhabas/api/domain/contest/usecase/ContestBoardServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/contest/usecase/ContestBoardServiceImpl.java index 040989bd..2492df57 100644 --- a/resource-server/src/main/java/com/inhabas/api/domain/contest/usecase/ContestBoardServiceImpl.java +++ b/resource-server/src/main/java/com/inhabas/api/domain/contest/usecase/ContestBoardServiceImpl.java @@ -36,8 +36,6 @@ public class ContestBoardServiceImpl implements ContestBoardService { private final ContestBoardRepository contestBoardRepository; - private final ContestFieldRepository contestFieldRepository; - private final BoardSecurityChecker boardSecurityChecker; private final MemberRepository memberRepository; @@ -67,6 +65,7 @@ public List getContestBoardsByType( return contestBoardList.stream() .map( contestBoard -> { + //첨부파일들 중 첫번째 이미지 = 썸네일 FileDownloadDto thumbnail = contestBoard.getFiles().stream() .filter(file -> isImageFile(file.getName()))