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(); + } }