diff --git a/src/main/java/com/backend/soullive_a/controller/ModelController.java b/src/main/java/com/backend/soullive_a/controller/ModelController.java index e91d5ca..1be8a7d 100644 --- a/src/main/java/com/backend/soullive_a/controller/ModelController.java +++ b/src/main/java/com/backend/soullive_a/controller/ModelController.java @@ -16,16 +16,16 @@ public class ModelController { /** * 모델 조회 api - * @param modelId + * @param modelName * @return */ - @GetMapping("/{modelId}") - public BaseResponse getModel(@PathVariable Long modelId) { + @GetMapping("") + public BaseResponse getModel(@RequestParam String modelName) { return BaseResponse.builder() .isSuccess(true) .code(200) .message("모델 조회에 성공했습니다.") - .data(modelService.getModel(modelId)) + .data(modelService.getModel(modelName)) .build(); } diff --git a/src/main/java/com/backend/soullive_a/controller/ModelIntroductionController.java b/src/main/java/com/backend/soullive_a/controller/ModelIntroductionController.java index 827959e..8e1b4bd 100644 --- a/src/main/java/com/backend/soullive_a/controller/ModelIntroductionController.java +++ b/src/main/java/com/backend/soullive_a/controller/ModelIntroductionController.java @@ -19,16 +19,16 @@ public class ModelIntroductionController { /** * 모델소개 조회 api - * @param modelId + * @param modelName * @return */ - @GetMapping("/{modelId}") - public BaseResponse getModelIntroduction(@PathVariable Long modelId) { + @GetMapping("") + public BaseResponse getModelIntroduction(@RequestParam String modelName) { return BaseResponse.builder() .isSuccess(true) .code(2006) .message("모델소개 정보 조회에 성공했습니다.") - .data(modelIntroductionService.getModelIntroduction(modelId)) + .data(modelIntroductionService.getModelIntroduction(modelName)) .build(); } diff --git a/src/main/java/com/backend/soullive_a/dto/request/ModelRequest.java b/src/main/java/com/backend/soullive_a/dto/request/ModelRequest.java index d5ed157..9809e9a 100644 --- a/src/main/java/com/backend/soullive_a/dto/request/ModelRequest.java +++ b/src/main/java/com/backend/soullive_a/dto/request/ModelRequest.java @@ -1,5 +1,6 @@ package com.backend.soullive_a.dto.request; +import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import java.time.LocalDate; @@ -8,12 +9,14 @@ public record ModelRequest( String imageUrl, String modelName, - LocalDate birth, - String age, - String job, + LocalDate birth, + String age, + String job, String info, - String agency, - Float aiRate) { + String agency, + + + Float aiRate) { } diff --git a/src/main/java/com/backend/soullive_a/repository/ModelRepository.java b/src/main/java/com/backend/soullive_a/repository/ModelRepository.java index 6f35486..ba26875 100644 --- a/src/main/java/com/backend/soullive_a/repository/ModelRepository.java +++ b/src/main/java/com/backend/soullive_a/repository/ModelRepository.java @@ -8,4 +8,5 @@ public interface ModelRepository extends JpaRepository { + public Optional findByModelName(String modelName); } diff --git a/src/main/java/com/backend/soullive_a/repository/ModelImageKeywordRepository.java b/src/main/java/com/backend/soullive_a/repository/model/introduction/ModelImageKeywordRepository.java similarity index 85% rename from src/main/java/com/backend/soullive_a/repository/ModelImageKeywordRepository.java rename to src/main/java/com/backend/soullive_a/repository/model/introduction/ModelImageKeywordRepository.java index 80bf8ee..40dc1ff 100644 --- a/src/main/java/com/backend/soullive_a/repository/ModelImageKeywordRepository.java +++ b/src/main/java/com/backend/soullive_a/repository/model/introduction/ModelImageKeywordRepository.java @@ -1,4 +1,4 @@ -package com.backend.soullive_a.repository; +package com.backend.soullive_a.repository.model.introduction; import com.backend.soullive_a.entity.model.Model; diff --git a/src/main/java/com/backend/soullive_a/repository/ModelIntroductionRepository.java b/src/main/java/com/backend/soullive_a/repository/model/introduction/ModelIntroductionRepository.java similarity index 59% rename from src/main/java/com/backend/soullive_a/repository/ModelIntroductionRepository.java rename to src/main/java/com/backend/soullive_a/repository/model/introduction/ModelIntroductionRepository.java index 85422c5..54110ac 100644 --- a/src/main/java/com/backend/soullive_a/repository/ModelIntroductionRepository.java +++ b/src/main/java/com/backend/soullive_a/repository/model/introduction/ModelIntroductionRepository.java @@ -1,10 +1,12 @@ -package com.backend.soullive_a.repository; +package com.backend.soullive_a.repository.model.introduction; +import com.backend.soullive_a.entity.model.Model; import com.backend.soullive_a.entity.model.introduction.ModelIntroduction; import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; public interface ModelIntroductionRepository extends JpaRepository { + public ModelIntroduction findByModelModelName(String name); } diff --git a/src/main/java/com/backend/soullive_a/repository/ModelRecentAdvertisementRepository.java b/src/main/java/com/backend/soullive_a/repository/model/introduction/ModelRecentAdvertisementRepository.java similarity index 88% rename from src/main/java/com/backend/soullive_a/repository/ModelRecentAdvertisementRepository.java rename to src/main/java/com/backend/soullive_a/repository/model/introduction/ModelRecentAdvertisementRepository.java index 8f59158..d89340b 100644 --- a/src/main/java/com/backend/soullive_a/repository/ModelRecentAdvertisementRepository.java +++ b/src/main/java/com/backend/soullive_a/repository/model/introduction/ModelRecentAdvertisementRepository.java @@ -1,4 +1,4 @@ -package com.backend.soullive_a.repository; +package com.backend.soullive_a.repository.model.introduction; import com.backend.soullive_a.entity.model.Model; diff --git a/src/main/java/com/backend/soullive_a/repository/ModelRecentWorkRepository.java b/src/main/java/com/backend/soullive_a/repository/model/introduction/ModelRecentWorkRepository.java similarity index 85% rename from src/main/java/com/backend/soullive_a/repository/ModelRecentWorkRepository.java rename to src/main/java/com/backend/soullive_a/repository/model/introduction/ModelRecentWorkRepository.java index ae25529..0dd822e 100644 --- a/src/main/java/com/backend/soullive_a/repository/ModelRecentWorkRepository.java +++ b/src/main/java/com/backend/soullive_a/repository/model/introduction/ModelRecentWorkRepository.java @@ -1,4 +1,4 @@ -package com.backend.soullive_a.repository; +package com.backend.soullive_a.repository.model.introduction; import com.backend.soullive_a.entity.model.Model; diff --git a/src/main/java/com/backend/soullive_a/service/ModelIntroductionService.java b/src/main/java/com/backend/soullive_a/service/ModelIntroductionService.java index d3d09df..c648ce2 100644 --- a/src/main/java/com/backend/soullive_a/service/ModelIntroductionService.java +++ b/src/main/java/com/backend/soullive_a/service/ModelIntroductionService.java @@ -7,7 +7,7 @@ import java.util.List; public interface ModelIntroductionService { - public ModelIntroductionResponse getModelIntroduction(Long modelId); + public ModelIntroductionResponse getModelIntroduction(String modelName); public ModelIntroductionResponse createModelIntroduction(ModelIntroduceRequest request, Long modelId); } diff --git a/src/main/java/com/backend/soullive_a/service/ModelService.java b/src/main/java/com/backend/soullive_a/service/ModelService.java index 0458e36..05d1757 100644 --- a/src/main/java/com/backend/soullive_a/service/ModelService.java +++ b/src/main/java/com/backend/soullive_a/service/ModelService.java @@ -4,7 +4,7 @@ import com.backend.soullive_a.dto.response.ModelResponse; public interface ModelService { - public ModelResponse getModel(Long modelId ); + public ModelResponse getModel(String modelName ); public ModelResponse createModel(ModelRequest request); } diff --git a/src/main/java/com/backend/soullive_a/service/impl/ModelIntroductionServiceImpl.java b/src/main/java/com/backend/soullive_a/service/impl/ModelIntroductionServiceImpl.java index f58d555..3881e22 100644 --- a/src/main/java/com/backend/soullive_a/service/impl/ModelIntroductionServiceImpl.java +++ b/src/main/java/com/backend/soullive_a/service/impl/ModelIntroductionServiceImpl.java @@ -4,7 +4,6 @@ import com.backend.soullive_a.dto.request.ModelIntroduceRequest; import com.backend.soullive_a.dto.request.ModelRecentAdvertisementRequest; import com.backend.soullive_a.dto.request.ModelRecentWorkRequest; -import com.backend.soullive_a.dto.response.ModelImageKeywordResponse; import com.backend.soullive_a.dto.response.ModelIntroductionResponse; import com.backend.soullive_a.dto.response.ModelRecentAdvertisementResponse; import com.backend.soullive_a.dto.response.ModelRecentWorkResponse; @@ -15,16 +14,18 @@ import com.backend.soullive_a.entity.model.introduction.ModelRecentWork; import com.backend.soullive_a.exception.custom.NotFoundUserException; import com.backend.soullive_a.repository.*; +import com.backend.soullive_a.repository.model.introduction.ModelImageKeywordRepository; +import com.backend.soullive_a.repository.model.introduction.ModelIntroductionRepository; +import com.backend.soullive_a.repository.model.introduction.ModelRecentAdvertisementRepository; +import com.backend.soullive_a.repository.model.introduction.ModelRecentWorkRepository; import com.backend.soullive_a.service.ModelIntroductionService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Slf4j @@ -45,8 +46,8 @@ public class ModelIntroductionServiceImpl implements ModelIntroductionService { * @return */ @Override - public ModelIntroductionResponse getModelIntroduction(Long modelId) { - Model model = modelRepository.findById(modelId) + public ModelIntroductionResponse getModelIntroduction(String modelName) { + Model model = modelRepository.findByModelName(modelName) .orElseThrow(() -> new NotFoundUserException()); List modelImageKeywords = modelImageKeywordRepository.findAllByModel(model); diff --git a/src/main/java/com/backend/soullive_a/service/impl/ModelServiceImpl.java b/src/main/java/com/backend/soullive_a/service/impl/ModelServiceImpl.java index d4663d2..58ec9fa 100644 --- a/src/main/java/com/backend/soullive_a/service/impl/ModelServiceImpl.java +++ b/src/main/java/com/backend/soullive_a/service/impl/ModelServiceImpl.java @@ -17,8 +17,9 @@ public class ModelServiceImpl implements ModelService { private final ModelRepository modelRepository; @Override - public ModelResponse getModel(Long modelId) { - Model model = modelRepository.findById(modelId) + public ModelResponse getModel(String modelName) { + System.out.println(modelName); + Model model = modelRepository.findByModelName(modelName) .orElseThrow(() -> new NotFoundUserException()); return ModelResponse.builder()