Skip to content

Commit

Permalink
Merge pull request #57 from Beyond-B/fix/55-diary-create
Browse files Browse the repository at this point in the history
♻️ [Refactor]: 일기 등록 수정
  • Loading branch information
jinuklee777 authored Feb 16, 2024
2 parents 3c6e042 + 9aa4150 commit ddff264
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static DiaryResponseDTO.DiaryContentDTO toDiaryContentDTO(Diary diary) {
.emotionSpecific(diary.getEmotionSpecific())
.behavior(diary.getBehavior())
.result(diary.getResult())
.feeling(diary.getFeeling().getEmotion())
.build();
}
public static DiaryResponseDTO.MonthlyDiaryDTO toMonthlyDiaryDTO(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,18 @@ public Diary updateDiary(DiaryRequestDTO.UpdateDiaryDTO request){

@Transactional
public Diary createDiary(DiaryRequestDTO.CreateDiaryDTO request, User user) {
Feeling feeling = feelingRepository.findByEmotion(request.getEmotion());

Diary diary = Diary.builder().user(user)
.behavior(request.getBehavior())
.result(request.getResult())
.thought(request.getThought())
.event(request.getEvent())
.date(request.getDate())
.emotionSpecific(request.getEmotionSpecific())

.feeling(feeling)
.build();

Emotion emotion = request.getEmotion();
Feeling feeling = feelingRepository.findByEmotion(emotion);

diary.setFeeling(feeling);


diaryRepository.save(diary);
return diary;
}
Expand Down

0 comments on commit ddff264

Please sign in to comment.