Skip to content

Commit

Permalink
[refactor] 자기소개 코드 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
oosedus committed Sep 6, 2024
1 parent 1413265 commit 59bed15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.letscareer.self_intro.domain.model;

import com.example.letscareer.self_intro.domain.dto.SelfIntroDTO;
import com.example.letscareer.stage.domain.model.Stage;
import jakarta.persistence.*;
import lombok.*;
Expand Down Expand Up @@ -27,4 +28,13 @@ public class SelfIntro {
@JoinColumn(name = "stageId")
@NotNull
private Stage stage;

public static SelfIntro of(SelfIntroDTO selfIntroDTO, Stage stage) {
return SelfIntro.builder()
.title(selfIntroDTO.title())
.sequence(selfIntroDTO.sequence())
.content(selfIntroDTO.content())
.stage(stage)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ public void saveSelfIntro(Long userId, Long scheduleId, Long stageId, SaveSelfIn

// 새로 들어온 자기소개서 항목을 저장한다.
for (SelfIntroDTO selfIntroDTO : request.selfIntros()) {
SelfIntro selfIntro = SelfIntro.builder()
.title(selfIntroDTO.title())
.sequence(selfIntroDTO.sequence())
.content(selfIntroDTO.content())
.stage(stage)
.build();
SelfIntro selfIntro = SelfIntro.of(selfIntroDTO, stage);
selfIntroRepository.save(selfIntro);
}
}
Expand Down

0 comments on commit 59bed15

Please sign in to comment.