Skip to content

Commit

Permalink
Fix: 러닝 경로가 빈 리스트일 경우 좌표를 0,0,0인 지점을 저장하게 수정 (#328)
Browse files Browse the repository at this point in the history
* Fix: 러닝 경로가 빈 리스트일 경우 Exception -> 좌표를 0,0,0인 지점을 저장하게 수정

* Fix: 러닝 경로 startPoint, endPoint null 체크
  • Loading branch information
hee9841 authored Dec 30, 2024
1 parent 027d91b commit 737be63
Show file tree
Hide file tree
Showing 3 changed files with 13 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 @@ -2,14 +2,17 @@


import com.dnd.runus.domain.common.CoordinatePoint;
import jakarta.validation.constraints.NotNull;

/**
* 클라이언트와의 러닝 경로 요청/응답 형식
* @param start 시작 위치
* @param end 종료 위치
*/
public record RouteDtoV2(
@NotNull
Point start,
@NotNull
Point end
) {
public record Point(double longitude, double latitude) {
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 737be63

Please sign in to comment.