Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ public interface PreparationUserRepository extends JpaRepository<PreparationUser
@Modifying
@Query("UPDATE PreparationUser p SET p.nextPreparation = NULL WHERE p.user.id = :userId")
void clearNextPreparationByUserId(@Param("userId") Long userId);

boolean existsByUser(User user);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public enum ErrorCode {
FIREBASE(1011, "FIREBASE로 메세지를 발송하였으나 오류가 발생했습니다.(유효하지 않은 토큰 등)", HttpStatus.BAD_REQUEST),
FIRST_PREPARATION_NOT_FOUND(1012, "해당 ID의 사용자의 준비과정을 찾을 수 없습니다.", HttpStatus.BAD_REQUEST),
NOTIFICATION_NOT_FOUND(1013, "알림을 찾을 수 없습니다.", HttpStatus.BAD_REQUEST ),
PREPARATION_ALREADY_EXISTS(1014, "해당 사용자의 준비과정이 이미 존재합니다.", HttpStatus.BAD_REQUEST),

// 공통 오류 메시지
UNEXPECTED_ERROR(1000, "Unexpected Error: An unexpected error occurred.", HttpStatus.INTERNAL_SERVER_ERROR),;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public void setFirstPreparationUser(Long userId, List<PreparationDto> preparatio
User user = userRepository.findById(userId).orElseThrow(() ->
new GeneralException(USER_NOT_FOUND)
);
boolean exists = preparationUserRepository.existsByUser(user);
if (exists) {
throw new GeneralException(PREPARATION_ALREADY_EXISTS);
}
handlePreparationUsers(user, preparationDtoList, false);

}
Expand Down