Skip to content

Commit

Permalink
[feat] 일정 삭제시 북마크도 같이 삭제하는 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
JeonHaeseung committed Jul 16, 2024
1 parent b37e570 commit 825a342
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package Ness.Backend.domain.schedule;

import Ness.Backend.domain.bookmark.BookmarkRepository;
import Ness.Backend.domain.bookmark.entity.Bookmark;
import Ness.Backend.domain.category.CategoryRepository;
import Ness.Backend.domain.category.entity.Category;
import Ness.Backend.domain.chat.ChatRepository;
Expand Down Expand Up @@ -38,6 +40,7 @@
public class ScheduleService {
private final ScheduleRepository scheduleRepository;
private final MemberRepository memberRepository;
private final BookmarkRepository bookmarkRepository;
private final CategoryRepository categoryRepository;
private final ChatRepository chatRepository;
private final ChatService chatService;
Expand Down Expand Up @@ -158,6 +161,7 @@ public GetChatListDto postAiScheduleAccept(Long memberId, Boolean idAccepted, Lo
/* 사용자가 직접 삭제한 스케쥴 */
public GetScheduleListDto deleteSchedule(Long memberId, Long scheduleId){
Schedule schedule = scheduleRepository.findScheduleById(scheduleId);
List<Bookmark> bookmarks = bookmarkRepository.findBookmarksBySchedule_Id(scheduleId);
ZonedDateTime scheduleTime = schedule.getStartTime().withZoneSameInstant(ZoneId.of("Asia/Seoul"));

//VectorDB에서 삭제
Expand All @@ -174,6 +178,7 @@ public GetScheduleListDto deleteSchedule(Long memberId, Long scheduleId){
}

//RDB에서 삭제
bookmarkRepository.deleteAll(bookmarks);
scheduleRepository.delete(schedule);

return getOneDayUserSchedule(memberId, scheduleTime);
Expand All @@ -182,6 +187,7 @@ public GetScheduleListDto deleteSchedule(Long memberId, Long scheduleId){
/* 사용자가 AI가 삭제 요청한 스케쥴을 Accept/Deny한 여부에 따라서 채팅 및 스케쥴 저장 */
public GetChatListDto deleteAiScheduleAccept(Long memberId, Boolean idAccepted, Long scheduleId){
Member member = memberRepository.findMemberById(memberId);
List<Bookmark> bookmarks = bookmarkRepository.findBookmarksBySchedule_Id(scheduleId);
Schedule schedule = scheduleRepository.findScheduleById(scheduleId);

/* 사용자가 Accept 했으면 스케쥴 생성하기 */
Expand All @@ -204,6 +210,7 @@ public GetChatListDto deleteAiScheduleAccept(Long memberId, Boolean idAccepted,
String info = schedule.getInfo();

//RDB에서 삭제
bookmarkRepository.deleteAll(bookmarks);
scheduleRepository.delete(schedule);

chatService.createNewChat("\"" + info + "\" " + "일정을 삭제해드렸습니다!", ChatType.AI, 1, member);
Expand Down

0 comments on commit 825a342

Please sign in to comment.