Skip to content

Commit

Permalink
Merge pull request #243 from TEAM-MODDY/refactor/#242
Browse files Browse the repository at this point in the history
#242 [refactor] 지원서 상세보기 api modelId 를 applicationDto 에서 참조
  • Loading branch information
pkl0912 authored Feb 11, 2024
2 parents c60054e + 3bd18a7 commit 0362eed
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public SuccessResponse<ApplicationDetailInfoResponse> 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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;

public record ApplicationDto(
Long modelId,
String modelImgUrl,
String hairLength,
List<String> preferHairStyleList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PreferHairStyle> preferHairStyles = preferHairStyleJpaRepository.findAllByHairModelApplicationId(applicationId);
List<String> preferhairStyleList = preferHairStyles.stream().map(hairStyle -> {
return hairStyle.getHairStyle().getValue();
Expand All @@ -78,6 +79,7 @@ public ApplicationDto getApplicationDetailInfo(final Long applicationId){
}).collect(Collectors.toList());

return new ApplicationDto(
modelId,
hairModelApplication.getModelImgUrl(),
hairModelApplication.getHairLength().getValue(),
preferhairStyleList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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();
}
}

0 comments on commit 0362eed

Please sign in to comment.