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