From d09c7e2fdc269937b955ced354a9968ea48cb92b Mon Sep 17 00:00:00 2001 From: oosedus Date: Mon, 2 Sep 2024 21:29:48 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20=EC=9E=90=EA=B8=B0=EC=86=8C=EA=B0=9C?= =?UTF-8?q?=EC=84=9C=20=EC=97=AC=EB=9F=AC=EA=B0=9C=20=EB=93=B1=EB=A1=9D=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SelfIntroController.java | 2 +- .../self_intro/domain/SelfIntro.java | 2 +- .../self_intro/service/SelfIntroService.java | 18 +++++++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/example/letscareer/self_intro/controller/SelfIntroController.java b/src/main/java/com/example/letscareer/self_intro/controller/SelfIntroController.java index 611d85d..ab7ebae 100644 --- a/src/main/java/com/example/letscareer/self_intro/controller/SelfIntroController.java +++ b/src/main/java/com/example/letscareer/self_intro/controller/SelfIntroController.java @@ -6,7 +6,7 @@ import com.example.letscareer.common.exception.enums.SuccessCode; import com.example.letscareer.common.exception.model.BadRequestException; import com.example.letscareer.common.exception.model.NotFoundException; -import com.example.letscareer.self_intro.dto.SaveSelfIntroRequest; +import com.example.letscareer.self_intro.dto.request.SaveSelfIntroRequest; import com.example.letscareer.self_intro.service.SelfIntroService; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/com/example/letscareer/self_intro/domain/SelfIntro.java b/src/main/java/com/example/letscareer/self_intro/domain/SelfIntro.java index bf61b75..2a8322c 100644 --- a/src/main/java/com/example/letscareer/self_intro/domain/SelfIntro.java +++ b/src/main/java/com/example/letscareer/self_intro/domain/SelfIntro.java @@ -24,7 +24,7 @@ public class SelfIntro { @Lob private String content; - @OneToOne(fetch = FetchType.LAZY) + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "stageId") @NotNull private Stage stage; diff --git a/src/main/java/com/example/letscareer/self_intro/service/SelfIntroService.java b/src/main/java/com/example/letscareer/self_intro/service/SelfIntroService.java index 29f15c2..d77b7ba 100644 --- a/src/main/java/com/example/letscareer/self_intro/service/SelfIntroService.java +++ b/src/main/java/com/example/letscareer/self_intro/service/SelfIntroService.java @@ -4,7 +4,8 @@ import com.example.letscareer.schedule.domain.Schedule; import com.example.letscareer.schedule.repository.ScheduleRepository; import com.example.letscareer.self_intro.domain.SelfIntro; -import com.example.letscareer.self_intro.dto.SaveSelfIntroRequest; +import com.example.letscareer.self_intro.dto.SelfIntroDTO; +import com.example.letscareer.self_intro.dto.request.SaveSelfIntroRequest; import com.example.letscareer.self_intro.repository.SelfIntroRepository; import com.example.letscareer.stage.domain.Stage; import com.example.letscareer.stage.repository.StageRepository; @@ -36,11 +37,14 @@ public void saveSelfIntro(Long userId, Long scheduleId, Long stageId, SaveSelfIn User user = userRepository.findById(userId) .orElseThrow(() -> new NotFoundException(USER_NOT_FOUND_EXCEPTION)); - SelfIntro selfIntro = SelfIntro.builder() - .stage(stage) - .content(request.content()) - .build(); - - selfIntroRepository.save(selfIntro); + for(SelfIntroDTO selfIntroDTO : request.selfIntros()) { + SelfIntro selfIntro = SelfIntro.builder() + .title(selfIntroDTO.title()) + .sequence(selfIntroDTO.sequence()) + .content(selfIntroDTO.content()) + .stage(stage) + .build(); + selfIntroRepository.save(selfIntro); + } } }