Skip to content

Commit

Permalink
feat : #18 Model 레포지토리, dto, 서비스 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
j2noo committed Mar 4, 2024
1 parent 737f436 commit 481331b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.backend.soullive_a.dto.request;

public record ModelRequest(Long modelId) {
}
Original file line number Diff line number Diff line change
@@ -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

) {}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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();
}

}

0 comments on commit 481331b

Please sign in to comment.