From c9e5f541be1cd8d5c7e9611b933cdbdef5dec6dd Mon Sep 17 00:00:00 2001 From: Sejeong Kim <64718002+clean2001@users.noreply.github.com> Date: Sat, 3 Aug 2024 17:29:43 +0900 Subject: [PATCH] =?UTF-8?q?fix/83:=20=ED=85=9C=ED=94=8C=EB=A6=BF=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EB=A6=AC=EB=B7=B0=20=EC=82=AC=ED=95=AD=20?= =?UTF-8?q?=EB=B0=98=EC=98=81=20(#85)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: 필요없는 로그 코드 삭제 * chore: 모든 템플릿 조회 FormType으로 변경 * chore: 기본 템플릿 아이디 리스트 삭제 * chore: application-dev 수정 --- .../layer/domain/template/service/TemplateService.java | 8 +++----- .../org/layer/domain/form/repository/FormRepository.java | 9 +++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/layer-api/src/main/java/org/layer/domain/template/service/TemplateService.java b/layer-api/src/main/java/org/layer/domain/template/service/TemplateService.java index 3a6378ed..bf44a6b9 100644 --- a/layer-api/src/main/java/org/layer/domain/template/service/TemplateService.java +++ b/layer-api/src/main/java/org/layer/domain/template/service/TemplateService.java @@ -15,9 +15,10 @@ import org.layer.domain.template.repository.TemplateMetadataRepository; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.List; +import static org.layer.domain.form.entity.FormType.TEMPLATE; + @Slf4j @RequiredArgsConstructor @Service @@ -27,8 +28,6 @@ public class TemplateService { private final QuestionRepository questionRepository; private final QuestionDescriptionRepository questionDescriptionRepository; - private static List templateIds = new ArrayList<>(List.of(10000L, 10001L, 10002L, 10003L, 10004L, 10005L)); - //== 간단 정보 단건 조회 ==// public TemplateSimpleInfoResponse getTemplateSimpleInfo(Long formId) { Form form = formRepository.findByIdOrThrow(formId); @@ -42,7 +41,6 @@ public TemplateDetailInfoResponse getTemplateDetailInfo(Long formId) { TemplateMetadata template = templateMetadataRepository.findByFormIdOrThrow(formId); List questionList = questionRepository.findAllByFormId(formId); - log.info("line 40: {}", questionList); List questionDesList = questionList.stream().map(q -> { QuestionDescription description = questionDescriptionRepository.findByQuestionIdOrThrow(q.getId()); @@ -58,7 +56,7 @@ public TemplateDetailInfoResponse getTemplateDetailInfo(Long formId) { //== 모든 템플릿 리스트 간단 정보 조회 ==// public List getAllTemplates() { - List
forms = formRepository.findAllById(templateIds); + List forms = formRepository.findByFormTypeOrderById(TEMPLATE); return forms.stream().map(form -> { TemplateMetadata metadata = templateMetadataRepository.findByFormIdOrThrow(form.getId()); diff --git a/layer-domain/src/main/java/org/layer/domain/form/repository/FormRepository.java b/layer-domain/src/main/java/org/layer/domain/form/repository/FormRepository.java index 9a348a03..18fd602f 100644 --- a/layer-domain/src/main/java/org/layer/domain/form/repository/FormRepository.java +++ b/layer-domain/src/main/java/org/layer/domain/form/repository/FormRepository.java @@ -1,16 +1,21 @@ package org.layer.domain.form.repository; -import static org.layer.common.exception.FormExceptionType.*; - import org.layer.domain.form.entity.Form; +import org.layer.domain.form.entity.FormType; import org.layer.domain.form.exception.FormException; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; + +import static org.layer.common.exception.FormExceptionType.NOT_FOUND_FORM; + public interface FormRepository extends JpaRepository { default Form findByIdOrThrow(Long formId) { return findById(formId) .orElseThrow(() -> new FormException(NOT_FOUND_FORM)); } + List findByFormTypeOrderById(FormType formType); + }