Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 러닝 경로가 빈 리스트일 경우 좌표를 0,0,0인 지점을 저장하게 수정 #328

Merged
merged 2 commits into from
Dec 30, 2024
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 @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제안

  • nullIsLandPoint 변수가 0, 0 좌표를 담고 있어서,
    null이란 네이밍보다는 empty나 missing 등으로 바꾸면 좋을 것도 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가 작업할 때 변경하겠습니다😄

route = List.of(
new RouteDtoV2(nullIsLandPoint, nullIsLandPoint)
);
}
}
}
}