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 new file mode 100644 index 0000000..ca6dc2d --- /dev/null +++ b/src/main/java/com/backend/soullive_a/dto/request/ModelRequest.java @@ -0,0 +1,4 @@ +package com.backend.soullive_a.dto.request; + +public record ModelRequest(Long modelId) { +} diff --git a/src/main/java/com/backend/soullive_a/dto/response/ModelResponse.java b/src/main/java/com/backend/soullive_a/dto/response/ModelResponse.java new file mode 100644 index 0000000..eb21424 --- /dev/null +++ b/src/main/java/com/backend/soullive_a/dto/response/ModelResponse.java @@ -0,0 +1,18 @@ +package com.backend.soullive_a.dto.response; + +import com.backend.soullive_a.entity.ModelIntroduction; +import lombok.Builder; + +import java.time.LocalDateTime; + +@Builder +public record ModelResponse( + Long modelId, + String modelName, + LocalDateTime birth, + String job, + String info, + String agency, + Float aiRate + +) {} diff --git a/src/main/java/com/backend/soullive_a/service/ModelService.java b/src/main/java/com/backend/soullive_a/service/ModelService.java new file mode 100644 index 0000000..b0ea8dd --- /dev/null +++ b/src/main/java/com/backend/soullive_a/service/ModelService.java @@ -0,0 +1,8 @@ +package com.backend.soullive_a.service; + +import com.backend.soullive_a.dto.request.ModelRequest; +import com.backend.soullive_a.dto.response.ModelResponse; + +public interface ModelService { + public ModelResponse getModel(ModelRequest request); +} 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 new file mode 100644 index 0000000..3604856 --- /dev/null +++ b/src/main/java/com/backend/soullive_a/service/impl/ModelServiceImpl.java @@ -0,0 +1,33 @@ +package com.backend.soullive_a.service.impl; + +import com.backend.soullive_a.dto.request.ModelRequest; +import com.backend.soullive_a.dto.response.ModelResponse; +import com.backend.soullive_a.entity.Model; +import com.backend.soullive_a.repository.ModelRepository; +import com.backend.soullive_a.service.ModelService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ModelServiceImpl implements ModelService { + + private final ModelRepository modelRepository; + + @Override + public ModelResponse getModel(ModelRequest request) { + Model model = modelRepository.findById(request.modelId()) + .orElseThrow(() -> new RuntimeException("존재하지 않는 아이디")); + + return ModelResponse.builder() + .modelId(model.getId()) + .modelName(model.getModelName()) + .birth(model.getBirth()) + .job(model.getJob()) + .info(model.getInfo()) + .agency(model.getAgency()) + .aiRate(model.getAiRate()) + .build(); + } + +}