-
Notifications
You must be signed in to change notification settings - Fork 0
[UNI-18] feat : route의 위험요소,주의요소 조회 및 업데이트(수정,삭제,생성) API 개발 #21
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7a2d6cd
[UNI-71]feat : 두 노드의 좌표를 통해 특정 간선을 조회하여 위험/주의요소를 반환하는 API 개발
thdgustjd1 9d85e7c
[UNI-71] feat : Utils 클래스에 double형 좌표를 Point 또는 WTK로 변환하는 static 메서드 작성
thdgustjd1 401093e
[UNI-71] feat : 코드 중복을 줄이기 위해 Route 엔티티에 Set 자료구조를 List로 변환하여 반환하는 메서…
thdgustjd1 958fe3b
[UNI-59] feat : 추후 route 테이블의 LineString을 사용하였을 때 성능비교를 위한 코드 작성 (Lin…
thdgustjd1 95b6166
[UNI-72] feat : 주의/위험요 제보 API 개발
thdgustjd1 77aa791
[UNI-72] feat : 주의/위험요 제보 API 개발 - Repository
thdgustjd1 e42eac1
[UNI-72] refactor : 테스트 중 발생한 문제 해결
thdgustjd1 f8ac523
[UNI-18] chore : 코드리뷰 반영 (메서드명 수정)
thdgustjd1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...va/com/softeer5/uniro_backend/common/exception/custom/DangerCautionConflictException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.softeer5.uniro_backend.common.exception.custom; | ||
|
|
||
| import com.softeer5.uniro_backend.common.error.ErrorCode; | ||
| import com.softeer5.uniro_backend.common.exception.CustomException; | ||
|
|
||
| public class DangerCautionConflictException extends CustomException { | ||
| public DangerCautionConflictException(String message, ErrorCode errorCode) { | ||
| super(message, errorCode); | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
.../main/java/com/softeer5/uniro_backend/common/exception/custom/RouteNotFoundException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.softeer5.uniro_backend.common.exception.custom; | ||
|
|
||
| import com.softeer5.uniro_backend.common.error.ErrorCode; | ||
| import com.softeer5.uniro_backend.common.exception.CustomException; | ||
|
|
||
| public class RouteNotFoundException extends CustomException { | ||
| public RouteNotFoundException(String message, ErrorCode errorCode) { | ||
| super(message, errorCode); | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
uniro_backend/src/main/java/com/softeer5/uniro_backend/common/utils/Utils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package com.softeer5.uniro_backend.common.utils; | ||
|
|
||
| import org.locationtech.jts.geom.Coordinate; | ||
| import org.locationtech.jts.geom.GeometryFactory; | ||
| import org.locationtech.jts.geom.LineString; | ||
| import org.locationtech.jts.geom.Point; | ||
| import org.locationtech.jts.io.WKTWriter; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public final class Utils { | ||
| private static final GeometryFactory geometryFactory = new GeometryFactory(); | ||
|
|
||
| private Utils(){ | ||
| // 인스턴스화 방지 | ||
| } | ||
|
|
||
| public static Point convertDoubleToPoint(double lat, double lng) { | ||
| return geometryFactory.createPoint(new Coordinate(lat, lng)); | ||
| } | ||
|
|
||
| public static String convertDoubleToPointWTK(double lat, double lng) { | ||
| return String.format("POINT(%f %f)", lat, lng); | ||
| } | ||
|
|
||
| public static LineString convertDoubleToLineString(List<double[]> co){ | ||
| if(co==null || co.isEmpty()){ | ||
| throw new IllegalArgumentException("coordinates can not be null or empty"); | ||
| } | ||
|
|
||
| Coordinate[] coordinates = new Coordinate[co.size()]; | ||
| for (int i = 0; i < co.size(); i++) { | ||
| coordinates[i] = new Coordinate(co.get(i)[0], co.get(i)[1]); | ||
| } | ||
|
|
||
| return geometryFactory.createLineString(coordinates); | ||
| } | ||
|
|
||
| public static String convertDoubleToLineStringWTK(List<double[]> co){ | ||
| LineString lineString = convertDoubleToLineString(co); | ||
| WKTWriter writer = new WKTWriter(); | ||
| return writer.write(lineString); | ||
| } | ||
|
|
||
|
Comment on lines
+18
to
+44
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이렇게 변환로직을 유틸로 만든거 좋은 것 같네요! |
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
uniro_backend/src/main/java/com/softeer5/uniro_backend/route/dto/GetRiskResDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.softeer5.uniro_backend.route.dto; | ||
|
|
||
| import com.softeer5.uniro_backend.route.entity.CautionType; | ||
| import com.softeer5.uniro_backend.route.entity.DangerType; | ||
| import com.softeer5.uniro_backend.route.entity.Route; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @Schema(name = "GetAllRoutesResDTO", description = "특정 간선의 주의/위험요소 조회 DTO") | ||
| @RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
| public class GetRiskResDTO { | ||
| @Schema(description = "route ID", example = "3") | ||
| private final Long routeId; | ||
| @Schema(description = "위험 요소 타입 리스트", example = "[\"SLOPE\", \"STAIRS\"]") | ||
| private final List<CautionType> cautionTypes; | ||
| @Schema(description = "위험 요소 타입 리스트", example = "[\"SLOPE\", \"STAIRS\"]") | ||
| private final List<DangerType> dangerTypes; | ||
|
|
||
| public static GetRiskResDTO of(Route route) { | ||
| return new GetRiskResDTO(route.getId(),route.getCautionFactorsByList(), route.getDangerFactorsByList()); | ||
| } | ||
|
|
||
| } |
15 changes: 15 additions & 0 deletions
15
uniro_backend/src/main/java/com/softeer5/uniro_backend/route/dto/PostRiskReqDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.softeer5.uniro_backend.route.dto; | ||
|
|
||
| import com.softeer5.uniro_backend.route.entity.CautionType; | ||
| import com.softeer5.uniro_backend.route.entity.DangerType; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| public class PostRiskReqDTO { | ||
| private List<CautionType> cautionTypes; | ||
| private List<DangerType> dangerTypes; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오,, 해당 처리 좋네요 ㅎㅎ