Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: 러닝 기록 저장 시(챌린지 모드) 사용하지 않는 챌린지 일경우 예외처리 추가
Browse files Browse the repository at this point in the history
hee9841 committed Dec 26, 2024

Verified

This commit was signed with the committer’s verified signature.
1 parent cb78b62 commit 2eccdc0
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -21,7 +21,9 @@
import com.dnd.runus.domain.running.DailyRunningRecordSummary;
import com.dnd.runus.domain.running.RunningRecord;
import com.dnd.runus.domain.running.RunningRecordRepository;
import com.dnd.runus.global.exception.BusinessException;
import com.dnd.runus.global.exception.NotFoundException;
import com.dnd.runus.global.exception.type.ErrorType;
import com.dnd.runus.presentation.v1.running.dto.WeeklyRunningRatingDto;
import com.dnd.runus.presentation.v1.running.dto.request.RunningRecordRequestV1;
import com.dnd.runus.presentation.v1.running.dto.request.RunningRecordWeeklySummaryType;
@@ -228,6 +230,9 @@ public RunningResultDto addRunningRecordV2(long memberId, RunningRecordRequestV2
.findById(request.challengeValues().challengeId())
.orElseThrow(() -> new NotFoundException(
Challenge.class, request.challengeValues().challengeId()));
if (!challenge.isActive()) {
throw new BusinessException(ErrorType.CHALLENGE_NOT_ACTIVE);
}

ChallengeAchievement challengeAchievement =
challengeAchievementRepository.save(new ChallengeAchievement(
Original file line number Diff line number Diff line change
@@ -50,6 +50,9 @@ public enum ErrorType {
GOAL_VALUES_REQUIRED_IN_GOAL_MODE(BAD_REQUEST, DEBUG, "RUNNING_005", "개인 목표 모드에서, 개인 목표 달성값은 필수 잆니다."),
CHALLENGE_VALUES_REQUIRED_IN_CHALLENGE_MODE(BAD_REQUEST, DEBUG, "RUNNING_006", "챌린지 모드에서, 챌린지 달성값은 필수 입니다."),

// ChallengeErrorType
CHALLENGE_NOT_ACTIVE(CONFLICT, DEBUG, "CHALLENGE_001", "해당 챌린지는 현재 활성화된 챌린지가 아닙니다."),

// WeatherErrorType
WEATHER_API_ERROR(SERVICE_UNAVAILABLE, WARN, "WEATHER_001", "날씨 API 호출 중 오류가 발생했습니다"),
;
Original file line number Diff line number Diff line change
@@ -58,7 +58,8 @@ public RunningRecordMonthlySummaryResponseV2 getMonthlyRunningSummary(@MemberId
ErrorType.CHALLENGE_VALUES_REQUIRED_IN_CHALLENGE_MODE,
ErrorType.GOAL_VALUES_REQUIRED_IN_GOAL_MODE,
ErrorType.GOAL_TIME_AND_DISTANCE_BOTH_EXIST,
ErrorType.ROUTE_MUST_HAVE_AT_LEAST_TWO_COORDINATES
ErrorType.ROUTE_MUST_HAVE_AT_LEAST_TWO_COORDINATES,
ErrorType.CHALLENGE_NOT_ACTIVE
})
@PostMapping
@ResponseStatus(HttpStatus.OK)

0 comments on commit 2eccdc0

Please sign in to comment.