Skip to content

Commit

Permalink
fix : 북마크 예외 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
zini9188 committed Nov 22, 2023
1 parent 89fcc3b commit ac43d11
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ public void createPhoto(Long scheduleId, Long dayId, List<MultipartFile> files)
public void createBookmark(Long scheduleId, SecurityUser securityUser) {
User findUser = userService.getVerifyUser(securityUser.getMember().getUserId());
Schedule findSchedule = getSchedule(scheduleId);
if (!findSchedule.getUser().getEmail().equals(findUser.getEmail())) {
throw new CustomException(ErrorCode.DIFFERENT_USER);
}
ScheduleBookmark scheduleBookmark = new ScheduleBookmark(findSchedule);
findUser.addScheduleBookmark(scheduleBookmark);
scheduleBookmarkRepository.save(scheduleBookmark);
Expand All @@ -165,6 +168,9 @@ public void createBookmark(Long scheduleId, SecurityUser securityUser) {
public void deleteBookmark(Long scheduleId, SecurityUser securityUser) {
User findUser = userService.getVerifyUser(securityUser.getMember().getUserId());
Schedule findSchedule = getSchedule(scheduleId);
if (!findSchedule.getUser().getEmail().equals(findUser.getEmail())) {
throw new CustomException(ErrorCode.DIFFERENT_USER);
}
scheduleBookmarkRepository.deleteByUserAndSchedule(findUser, findSchedule);
}

Expand Down

0 comments on commit ac43d11

Please sign in to comment.