Skip to content

Commit

Permalink
feat : 캐스퍼 커스텀 옵션 선택시 이미 존재하는 옵션이 존재하면 예외처리 (CC-123)
Browse files Browse the repository at this point in the history
  • Loading branch information
j2noo committed Aug 8, 2024
1 parent d92f1dd commit 7a2b515
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum ErrorCode implements BaseCode {
*/
NEED_AUTHENICATE(1000, "권한이 필요한 요청입니다,", HttpStatus.UNAUTHORIZED),
RACING_GAME_NOT_FOUND(2000, "등록된 레이싱게임이 없습니다.", HttpStatus.NOT_FOUND),
SELECTION_ALREADY_SELECTED(-2000, "이미 선택된 커스텀 옵션이 존재합니다.", HttpStatus.BAD_REQUEST);

/**
* 3xxx : 유저
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public SetSelectionResponseDto setSelectionOption(SetSelectionRequestDto req) {
RacingGameParticipant racingGameParticipant = racingGameParticipantRepository.findById(user.getId())
.orElseThrow(() -> new RacingGameException(ErrorCode.USER_NOT_FOUND));

// 이미 선택 옵션이 존재하는 경우, 예외를 던지
if (racingGameParticipant.isOptionSelected()) {
throw new RacingGameException(ErrorCode.SELECTION_ALREADY_SELECTED);
}

// 사용자가 선택한 커스텀 정보 업데이트
racingGameParticipant.setSelection(req.selection());
RacingGameParticipant saved = racingGameParticipantRepository.save(racingGameParticipant);
Expand Down

0 comments on commit 7a2b515

Please sign in to comment.