Skip to content

Commit

Permalink
Merge pull request #35 from NewMillenniumWorkout/dev/statistics
Browse files Browse the repository at this point in the history
[FIX] 일기 중복 생성 수정
  • Loading branch information
minseok128 authored Dec 4, 2024
2 parents 32c3821 + d7f8ab4 commit 28db6b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class DiaryController {

})
@PostMapping("/emotion/list")
public ResponseEntity<StatusResponseDto> sendInitMessage(@Parameter(hidden = true) @RequestHeader("Authorization") final String accessToken, @RequestParam("chatId") Long chatId) {
public ResponseEntity<StatusResponseDto> sendInitDiary(@Parameter(hidden = true) @RequestHeader("Authorization") final String accessToken, @RequestParam("chatId") Long chatId) {
String userEmail = jwtUtil.getEmail(accessToken.substring(7));
Optional<Member> member = memberService.findByEmail(userEmail);
Optional<Chat> chat = chatService.getChatById(chatId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.example.aneukbeserver.domain.member.Member;
import com.example.aneukbeserver.domain.selectedEmotion.SelectedEmotion;
import jakarta.persistence.EntityNotFoundException;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.LocalDateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
Expand All @@ -19,6 +21,7 @@
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
@Service
public class DiaryService {
@Autowired
Expand All @@ -28,7 +31,7 @@ public class DiaryService {
private ChatRepository chatRepository;

public void saveDiary(Chat chat, Member member) {
Diary diary = new Diary();
Diary diary = chat.getDiary();
diary.setChat(chat);
diary.setMember(member);
diary.setChat(chat);
Expand Down Expand Up @@ -112,6 +115,7 @@ public DiaryDTO getDateDiary(Member member, String date) {
if (diaries.isEmpty()) {
throw new EntityNotFoundException("Diary not found for member and date");
}

Diary diary = diaries.get(diaries.size() - 1);
// Diary diary = diaryRepository.findByMemberAndCreatedDate(member, localDate);

Expand Down

0 comments on commit 28db6b6

Please sign in to comment.