Skip to content

Commit

Permalink
[feat] 자기소개서 여러개 등록 로직 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
oosedus committed Sep 2, 2024
1 parent d2fcbfe commit d09c7e2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit d09c7e2

Please sign in to comment.