From 559cf8ac231380677a41af1af9a0b48e1e36b905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9E=AC=ED=98=81?= <67510260+LEEJaeHyeok97@users.noreply.github.com> Date: Wed, 14 Aug 2024 04:36:58 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20:sparkles:=20=EC=9D=BC=EA=B8=B0=20?= =?UTF-8?q?=EA=B0=90=EC=A0=95=20=EC=88=98=EC=A0=95=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20(#132)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial commit * Feat/#1 oauth2login (#3) * feat: User 엔터티 생성 * feat: jwt 버전 11->12, JWTUtil 생성 * feat: JWTFilter(JwtAuthenticationFilter) 등록 * feat: kakao 로그인 구현 * docs: swagger 태그(Authorization) 추가 (#5) * feat: User 엔터티 생성 * feat: jwt 버전 11->12, JWTUtil 생성 * feat: JWTFilter(JwtAuthenticationFilter) 등록 * feat: kakao 로그인 구현 * docs: swagger 태그(Authorization) 추가 * feat: accesstoken 테스트를 위한 test login 생성 (#9) * feat: User 엔티티에 상속 (#12) * feat: BaseEntity 생성 * feat: User 엔티티에 상속 * feat: 일기 생성 기능 구현 (#14) * feat: accesstoken 테스트를 위한 test login 생성 * feat: 일기 생성 기능 구현 * hotfix: ci 에러 수정 (#16) * feat: accesstoken 테스트를 위한 test login 생성 * feat: 일기 생성 기능 구현 * hotfix: ci 에러 수정 * fix: OIDC 카카오 로그인 nullPointerException 해결 * feat: 닉네임 설정 기능 구현 (#21) * feat: 일기 수정 기능 구현 (#25) * feat: 일기에 감정 컬럼 추가 * feat: 일기 수정 기능 구현 * feat: 일기 삭제 기능 구현 (#27) * feat: 일기에 감정 컬럼 추가 * feat: 일기 수정 기능 구현 * feat: 일기 삭제 기능 구현 * feat: 일기 감정 분석 기능 구현 (#31) * feat: 감정 저장 기능 구현 (#33) * feat: 일기 감정 분석 기능 구현 * feat: 감정 저장 기능 구현 * fix: :bug: 감정 저장 안되던 오류 수정 (#35) * feat: 일기 감정 분석 기능 구현 * feat: 감정 저장 기능 구현 * fix: :bug: 감정 저장 안되던 오류 수정 * hotfix: :ambulance: 서버 꺼짐 현상 해결 (#37) * feat: 일기 감정 분석 기능 구현 * feat: 감정 저장 기능 구현 * fix: :bug: 감정 저장 안되던 오류 수정 * hotfix: :ambulance: 서버 꺼짐 현상 해결 * feat: :sparkles: 홈 화면 조회 기능 구현 (#41) * feat: :sparkles: 회원가입 완료 여부 필드 추가 (#44) * feat: :sparkles: 일기 상세 조회 구현 (#47) * feat: :sparkles: 기간 별 감정 통계 조회 기능 구현 (#50) * feat: :sparkles: 일기 내용 검색 기능 구현 (#52) * feat: :sparkles: 감정 별 일기 조회 (#54) * feat: :sparkles: 월 별 일기 조회 기능 구현 (#59) * ci: :zap: workflow 수정 (#61) * ci: :zap: workflow 수정 * ci: :zap: workflow 수정 * feat: :sparkles: user 엔터티 fcmToken 컬럼 추가, 로그인 시 토큰 최신화 구현 (#63) * ci: :zap: workflow 수정 * ci: :zap: workflow 수정 * feat: :sparkles: fcm 토큰 알림 기능 구현 * feat: :sparkles: user 엔터티 fcmToken 컬럼 추가, 로그인 시 토큰 최신화 구현 * feat: :sparkles: 북마크 추가/삭제 기능 구현, 일기/홈화면 조회 쿼리문 수정 (#65) * feat: :sparkles: 북마크 추가 기능 구현 * feat: :sparkles: 북마크 추가/삭제 기능 구현, 일기/홈화면 조회 쿼리문 수정 * feat: :rocket: fcmtoken 등록 api 분리 (#68) * feat: :sparkles: 유저 정보 조회 기능 구현 (#71) * Feat/#70 user info (#73) * feat: :sparkles: 유저 정보 조회 기능 구현 * hotfix: :ambulance: cd 에러 해결 * refactor: :rocket: gpt prompt 수정 (#76) * feat: :sparkles: 일기 요약 스케줄러 구현 (#80) * refactor: :rocket: 엔터티 접근 지정자 수정 (#84) * feat: :sparkles: 챗봇 임베딩 및 대화 기능 구현 완료 (#86) * refactor: :rocket: 불필요한 필드 삭제, 검색 내용 글자 수정(10->25) (#89) * refactor: :hammer: 일기 검색 시 일기 id 값을 포함하도록 수정 * fix: :bug: 날짜 입력 안되던 현상 해결 (#93) * fix: :bug: string 형태로 받아오는 식으로 수정 (#95) * fix: :bug: 날짜 입력 안되던 현상 해결 * fix: :bug: string 형태로 받아오는 식으로 수정 * refactor: :hammer: 홈화면 조회에 다이어리 id 포함하도록 수정 * fix: :bug: 감정통계 정상 리턴 안되던 현상 수정 * feat: :sparkles: 감정 통계 리턴 dto 필드명 수정 * feat: :sparkles: 홈 화면 조회 시 내 일기만 조회하도록 수정 * feat: :sparkles: 감정 별 일기 조회 시 id값 함께 리턴하도록 수정 * feat: :sparkles: 채팅 내역 조회 기능 구현 (#106) * docs: :pencil2:채팅 히스토리 조회 문서 수정 (#108) * feat: :sparkles: 채팅 내역 조회 기능 구현 * docs: :pencil2:채팅 히스토리 조회 문서 수정 * feat: :sparkles: 채팅 히스토리 조회 시 생성 시각도 함께 반환 * feat: :sparkles: 챗봇과의 채팅 중 다시 응답 받는 기능 구현 (#111) * feat: :sparkles: 알림 기능 모두에게 보내도록 수정 (#114) * feat: :sparkles: 챗봇의 첫 인사 API 구현 (#116) * feat: :sparkles: 알림 기능 모두에게 보내도록 수정 * feat: :sparkles: 챗봇의 첫 인사 API 구현 * hotfix: :ambulance: 서버 restart * hotfix: :ambulance: docker restart * hotfix: :ambulance: 서버 재시작 * hotfix: :bug: Greeting 엔터티 중복 에러 삭제 * fix: 서버 timezone 설정 변경 적용 * fix: :bug: 시간 출력 수정(utc->seoul) * fix: :bug: 시간 출력 수정 test * fix: :bug: anxiety 걱정으로 쿼리되어 통계에 잡히지 않던 오류 수정 * feat: ai서버 주소 변경 적용 * feat: :sparkles: 회원 탈퇴 구현(카카오 연결 끊기x) * fix: :hammer: 감정 판단 prompt 수정 * feat: :sparkles: pdf 파일로 일기 가져오기 기능 구현 * fix: :hammer: 회원 탈퇴 전이 범위 설정 * fix: :hammer: bookmark 존재 시 diary 삭제 안되는 현상 수정 * fix: :hammer: cascade 타입 수정 * feat: :sparkles: 일기 감정 수정 기능 구현 --- .../emotion/application/EmotionService.java | 26 ++++++++++++++++++- .../emotion/dto/DiaryEditEmotionRes.java | 11 ++++++++ .../presentation/EmotionController.java | 14 ++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/aidiary/domain/emotion/dto/DiaryEditEmotionRes.java diff --git a/src/main/java/com/aidiary/domain/emotion/application/EmotionService.java b/src/main/java/com/aidiary/domain/emotion/application/EmotionService.java index 4be5f0e..c1f1a99 100644 --- a/src/main/java/com/aidiary/domain/emotion/application/EmotionService.java +++ b/src/main/java/com/aidiary/domain/emotion/application/EmotionService.java @@ -2,6 +2,7 @@ import com.aidiary.domain.diary.domain.Diary; import com.aidiary.domain.diary.domain.repository.DiaryRepository; +import com.aidiary.domain.emotion.dto.DiaryEditEmotionRes; import com.aidiary.domain.emotion.dto.DiarysByEmotionRes; import com.aidiary.domain.emotion.dto.EmotionStatRes; import com.aidiary.domain.user.domain.User; @@ -16,7 +17,6 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; -import java.util.List; @Service @RequiredArgsConstructor @@ -76,4 +76,28 @@ public Slice findDiarys(UserPrincipal userPrincipal, String Slice allByEmotionAndUserId = diaryRepository.findAllByEmotionAndUserId(emotion, userPrincipal.getId(), pageable); return allByEmotionAndUserId; } + + @Transactional + public DiaryEditEmotionRes editEmotion(Long userId, String emotion, Long diaryId) { + Diary diary = diaryRepository.findById(diaryId) + .orElseThrow(EntityNotFoundException::new); + + if (!diary.getUser().getId().equals(userId)) { + return DiaryEditEmotionRes + .builder() + .diaryId(diaryId) + .isEdited(false) + .emotion(diary.getEmotion()) + .build(); + } + + diary.updateEmotion(emotion); + + return DiaryEditEmotionRes + .builder() + .diaryId(diaryId) + .isEdited(true) + .emotion(emotion) + .build(); + } } diff --git a/src/main/java/com/aidiary/domain/emotion/dto/DiaryEditEmotionRes.java b/src/main/java/com/aidiary/domain/emotion/dto/DiaryEditEmotionRes.java new file mode 100644 index 0000000..4a8cafb --- /dev/null +++ b/src/main/java/com/aidiary/domain/emotion/dto/DiaryEditEmotionRes.java @@ -0,0 +1,11 @@ +package com.aidiary.domain.emotion.dto; + +import lombok.Builder; + +@Builder +public record DiaryEditEmotionRes( + Long diaryId, + boolean isEdited, + String emotion +) { +} diff --git a/src/main/java/com/aidiary/domain/emotion/presentation/EmotionController.java b/src/main/java/com/aidiary/domain/emotion/presentation/EmotionController.java index 2122d7b..3cc46dc 100644 --- a/src/main/java/com/aidiary/domain/emotion/presentation/EmotionController.java +++ b/src/main/java/com/aidiary/domain/emotion/presentation/EmotionController.java @@ -108,4 +108,18 @@ public ResponseCustom> findDiarysByEmotion( ) { return ResponseCustom.OK(emotionService.findDiarys(userPrincipal, emotion, pageable)); } + + @Operation(summary = "일기에 저장된 감정 수정", description = "일기에 저장된 감정을 수정합니다.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "감정 수정 성공", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = DiarysByEmotionRes.class))}), + @ApiResponse(responseCode = "400", description = "감정 수정 실패", content = {@Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))}), + }) + @PatchMapping("{diaryId}/{emotion}") + public ResponseCustom editDiaryEmotion( + @Parameter(description = "Accesstoken을 입력해주세요.", required = true) @CurrentUser UserPrincipal userPrincipal, + @Parameter(description = "수정할 감정(행복, 우울, 화남, 불안, 지루함)을 입력해주세요.", required = true) @PathVariable String emotion, + @Parameter(description = "감정을 수정할 일기의 id를 입력해주세요.", required = true) @PathVariable Long diaryId + ) { + return ResponseCustom.OK(emotionService.editEmotion(userPrincipal.getId(), emotion, diaryId)); + } }