From 3bd18a7b410e520be2e8ab99f147fc2c7387a175 Mon Sep 17 00:00:00 2001 From: pkl0912 Date: Sun, 11 Feb 2024 22:22:05 +0900 Subject: [PATCH] =?UTF-8?q?#242=20[refactor]=20modelId=20=EB=A5=BC=20appli?= =?UTF-8?q?cationDto=20=EC=97=90=EC=84=9C=20=EC=B0=B8=EC=A1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/application/ApplicationController.java | 3 +-- .../moddy/server/controller/model/dto/ApplicationDto.java | 1 + .../application/HairModelApplicationRetrieveService.java | 2 ++ .../moddy/server/service/model/ModelRetrieveService.java | 7 ------- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/moddy/server/controller/application/ApplicationController.java b/src/main/java/com/moddy/server/controller/application/ApplicationController.java index 1da3a1b1..3bdceb2c 100644 --- a/src/main/java/com/moddy/server/controller/application/ApplicationController.java +++ b/src/main/java/com/moddy/server/controller/application/ApplicationController.java @@ -90,8 +90,7 @@ public SuccessResponse getApplicationDetailInfo( @Parameter(hidden = true) @UserId Long designerId, @PathVariable(value = "applicationId") Long applicationId) { ApplicationDto applicationDto = hairModelApplicationRetrieveService.getApplicationDetailInfo(applicationId); - Long modelId = modelRetrieveService.getModelId(applicationId); - ApplicationModelInfoDto modelInfoDto = modelRetrieveService.getApplicationModelInfo(modelId); + ApplicationModelInfoDto modelInfoDto = modelRetrieveService.getApplicationModelInfo(applicationDto.modelId()); ApplicationInfoResponse applicationInfoResponse = new ApplicationInfoResponse( applicationId, applicationDto.modelImgUrl(), diff --git a/src/main/java/com/moddy/server/controller/model/dto/ApplicationDto.java b/src/main/java/com/moddy/server/controller/model/dto/ApplicationDto.java index bdbe3a4d..eb1b7b8a 100644 --- a/src/main/java/com/moddy/server/controller/model/dto/ApplicationDto.java +++ b/src/main/java/com/moddy/server/controller/model/dto/ApplicationDto.java @@ -5,6 +5,7 @@ import java.util.List; public record ApplicationDto( + Long modelId, String modelImgUrl, String hairLength, List preferHairStyleList, diff --git a/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java b/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java index 8d80d4ea..c86a6fde 100644 --- a/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java +++ b/src/main/java/com/moddy/server/service/application/HairModelApplicationRetrieveService.java @@ -61,6 +61,7 @@ public DesignerMainResponse getDesignerMainInfo(final Long designerId, final int } public ApplicationDto getApplicationDetailInfo(final Long applicationId){ HairModelApplication hairModelApplication = hairModelApplicationJpaRepository.findById(applicationId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); + Long modelId = hairModelApplication.getModel().getId(); List preferHairStyles = preferHairStyleJpaRepository.findAllByHairModelApplicationId(applicationId); List preferhairStyleList = preferHairStyles.stream().map(hairStyle -> { return hairStyle.getHairStyle().getValue(); @@ -78,6 +79,7 @@ public ApplicationDto getApplicationDetailInfo(final Long applicationId){ }).collect(Collectors.toList()); return new ApplicationDto( + modelId, hairModelApplication.getModelImgUrl(), hairModelApplication.getHairLength().getValue(), preferhairStyleList, diff --git a/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java b/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java index ebc022e1..c7b8fa97 100644 --- a/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java +++ b/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java @@ -4,7 +4,6 @@ import com.moddy.server.common.exception.model.NotFoundException; import com.moddy.server.controller.auth.dto.response.RegionResponse; import com.moddy.server.controller.model.dto.ApplicationModelInfoDto; -import com.moddy.server.domain.hair_model_application.HairModelApplication; import com.moddy.server.domain.hair_model_application.repository.HairModelApplicationJpaRepository; import com.moddy.server.domain.model.Model; import com.moddy.server.domain.model.repository.ModelJpaRepository; @@ -24,7 +23,6 @@ public class ModelRetrieveService { private final ModelJpaRepository modelJpaRepository; private final RegionJpaRepository regionJpaRepository; - private final HairModelApplicationJpaRepository hairModelApplicationJpaRepository; private final PreferRegionJpaRepository preferRegionJpaRepository; public ApplicationModelInfoDto getApplicationModelInfo(final Long modelId) { @@ -51,9 +49,4 @@ public String getModelName(final Long modelId) { Model model = modelJpaRepository.findById(modelId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_MODEL_INFO)); return model.getName(); } - - public Long getModelId(final Long applicationId) { - HairModelApplication application = hairModelApplicationJpaRepository.findById(applicationId).orElseThrow(() -> new NotFoundException(ErrorCode.NOT_FOUND_APPLICATION_EXCEPTION)); - return application.getModel().getId(); - } }