From e70abca864ad59a168019d25ae928f2160ca6e95 Mon Sep 17 00:00:00 2001 From: pkl0912 Date: Sun, 11 Feb 2024 16:27:12 +0900 Subject: [PATCH] =?UTF-8?q?#240=20[refactor]=20=EC=A7=80=EC=9B=90=EC=84=9C?= =?UTF-8?q?=20=EC=83=81=EC=84=B8=EB=B3=B4=EA=B8=B0=20api=20=EB=AA=A8?= =?UTF-8?q?=EB=8D=B8=20=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/application/ApplicationController.java | 3 ++- .../moddy/server/service/model/ModelRetrieveService.java | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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 4ac6db2d..1da3a1b1 100644 --- a/src/main/java/com/moddy/server/controller/application/ApplicationController.java +++ b/src/main/java/com/moddy/server/controller/application/ApplicationController.java @@ -90,7 +90,8 @@ public SuccessResponse getApplicationDetailInfo( @Parameter(hidden = true) @UserId Long designerId, @PathVariable(value = "applicationId") Long applicationId) { ApplicationDto applicationDto = hairModelApplicationRetrieveService.getApplicationDetailInfo(applicationId); - ApplicationModelInfoDto modelInfoDto = modelRetrieveService.getApplicationModelInfo(applicationId); + Long modelId = modelRetrieveService.getModelId(applicationId); + ApplicationModelInfoDto modelInfoDto = modelRetrieveService.getApplicationModelInfo(modelId); ApplicationInfoResponse applicationInfoResponse = new ApplicationInfoResponse( applicationId, applicationDto.modelImgUrl(), 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 0cecadfd..ebc022e1 100644 --- a/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java +++ b/src/main/java/com/moddy/server/service/model/ModelRetrieveService.java @@ -4,6 +4,8 @@ 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; import com.moddy.server.domain.prefer_region.PreferRegion; @@ -22,6 +24,7 @@ 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) { @@ -48,4 +51,9 @@ 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(); + } }