Skip to content

Commit

Permalink
Fix: 러닝 경로가 빈 리스트일 경우 Exception -> 좌표를 0,0,0인 지점을 저장하게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hee9841 committed Dec 28, 2024
1 parent 027d91b commit 409c617
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ 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.CHALLENGE_NOT_ACTIVE
})
@PostMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.dnd.runus.global.exception.BusinessException;
import com.dnd.runus.global.exception.type.ErrorType;
import com.dnd.runus.presentation.v2.running.dto.RouteDtoV2;
import com.dnd.runus.presentation.v2.running.dto.RouteDtoV2.Point;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand Down Expand Up @@ -58,11 +59,6 @@ public record RunningRecordRequestV2(
throw new BusinessException(ErrorType.GOAL_TIME_AND_DISTANCE_BOTH_EXIST);
}
}

//러닝 경로 유요성 확인
if(runningData.route() == null || runningData.route().size() < 2) {
throw new BusinessException(ErrorType.ROUTE_MUST_HAVE_AT_LEAST_TWO_COORDINATES);
}
}

public record ChallengeAchievedDto(
Expand Down Expand Up @@ -96,5 +92,14 @@ public record RunningRecordMetrics(
@Schema(description = "러닝 경로, 최소, 경로는 최소 2개의 좌표를 가져야합니다.")
List<RouteDtoV2> route
) {
public RunningRecordMetrics{
//러닝 경로 유요성 확인, 기본으로 null Point 좌표가 들어가게
if (route == null || route.isEmpty()) {
Point nullIsLandPoint = new Point(0, 0);
route = List.of(
new RouteDtoV2(nullIsLandPoint, nullIsLandPoint)
);
}
}
}
}

0 comments on commit 409c617

Please sign in to comment.