From 481331b07695cf1c5783a5afb0a6810065e88e2c Mon Sep 17 00:00:00 2001 From: j2noo Date: Mon, 4 Mar 2024 18:32:20 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20#18=20Model=20=EB=A0=88=ED=8F=AC?= =?UTF-8?q?=EC=A7=80=ED=86=A0=EB=A6=AC,=20dto,=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../soullive_a/dto/request/ModelRequest.java | 4 +++ .../dto/response/ModelResponse.java | 18 ++++++++++ .../soullive_a/service/ModelService.java | 8 +++++ .../service/impl/ModelServiceImpl.java | 33 +++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 src/main/java/com/backend/soullive_a/dto/request/ModelRequest.java create mode 100644 src/main/java/com/backend/soullive_a/dto/response/ModelResponse.java create mode 100644 src/main/java/com/backend/soullive_a/service/ModelService.java create mode 100644 src/main/java/com/backend/soullive_a/service/impl/ModelServiceImpl.java 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(); + } + +}