-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from moidot/feat/add-walk-path
feat: 대중교통 길찾기 실패 시 도보 경로 추천할 수 있도록 개선
- Loading branch information
Showing
13 changed files
with
478 additions
and
299 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
|
||
@Getter | ||
public enum TransportationType { | ||
PUBLIC, PERSONAL, NULL | ||
PUBLIC, PERSONAL, WALK, NULL | ||
} |
This file contains 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
105 changes: 105 additions & 0 deletions
105
src/main/java/com/moim/backend/domain/space/response/MoveUserInfo.java
This file contains 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,105 @@ | ||
package com.moim.backend.domain.space.response; | ||
|
||
import com.moim.backend.domain.space.entity.BestPlace; | ||
import com.moim.backend.domain.space.entity.Participation; | ||
import com.moim.backend.domain.space.entity.Space; | ||
import com.moim.backend.domain.space.entity.TransportationType; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class MoveUserInfo { | ||
@Schema(description = "모임장 여부") | ||
private Boolean isAdmin; | ||
@Schema(description = "사용자 아이디") | ||
private Long userId; | ||
@Schema(description = "사용자 닉네임") | ||
private String userName; | ||
@Schema(description = "이동 수단", allowableValues = {"PUBLIC", "PERSONAL", "WALK"}) | ||
private TransportationType transportationType; | ||
@Schema(description = "총 환승 횟수") | ||
private int transitCount; | ||
@Schema(description = "이동 시간. 단위: 분") | ||
private int totalTime; | ||
@Schema(description = "총 이동 거리 단위: 미터") | ||
private Double totalDistance; | ||
@Schema(description = "예상 요금") | ||
private int payment; | ||
@Schema(description = "이동 경로에 따른 좌표 리스트. 경로를 찾을 수 없을 경우, 비어있는 리스트로 반환") | ||
private List<PathDto> path = new ArrayList<>(); | ||
|
||
// 경로를 찾을 수 없는 사용자 | ||
public static MoveUserInfo createWithEmptyPath( | ||
Space space, | ||
Participation participation | ||
) { | ||
MoveUserInfo moveUserInfo = new MoveUserInfo(); | ||
moveUserInfo.isAdmin = (participation.getUserId() == space.getAdminId()) ? true : false; | ||
moveUserInfo.userId = participation.getUserId(); | ||
moveUserInfo.transportationType = participation.getTransportation(); | ||
moveUserInfo.userName = participation.getUserName(); | ||
return moveUserInfo; | ||
} | ||
|
||
public static MoveUserInfo createWithPublicPath( | ||
Space space, | ||
Participation participation, | ||
TmapPublicPathResponse tmapPublicPathResponse, | ||
List<PathDto> path | ||
) { | ||
MoveUserInfo moveUserInfo = new MoveUserInfo(); | ||
moveUserInfo.isAdmin = (participation.getUserId() == space.getAdminId()) ? true : false; | ||
moveUserInfo.userId = participation.getUserId(); | ||
moveUserInfo.userName = participation.getUserName(); | ||
moveUserInfo.transportationType = participation.getTransportation(); | ||
moveUserInfo.totalTime = tmapPublicPathResponse.getTotalTime(); | ||
moveUserInfo.totalDistance = tmapPublicPathResponse.getTotalDistance(); | ||
moveUserInfo.path = path; | ||
moveUserInfo.payment = tmapPublicPathResponse.getPayment(); | ||
return moveUserInfo; | ||
} | ||
|
||
public static MoveUserInfo createWithCarPath( | ||
Space space, | ||
Participation participation, | ||
CarPathResponse carPathResponse, | ||
BestPlace bestPlace | ||
) { | ||
MoveUserInfo moveUserInfo = new MoveUserInfo(); | ||
moveUserInfo.isAdmin = (participation.getUserId() == space.getAdminId()) ? true : false; | ||
moveUserInfo.userId = participation.getUserId(); | ||
moveUserInfo.userName = participation.getUserName(); | ||
moveUserInfo.transportationType = participation.getTransportation(); | ||
moveUserInfo.totalTime = carPathResponse.getTotalTime(); | ||
moveUserInfo.totalDistance = carPathResponse.getTotalDistance(); | ||
moveUserInfo.path = carPathResponse.getPathList(participation, bestPlace); | ||
moveUserInfo.payment = carPathResponse.getPayment(); | ||
return moveUserInfo; | ||
} | ||
|
||
public static MoveUserInfo createWithWalkPath( | ||
Space space, | ||
Participation participation, | ||
int totalTime, | ||
double totalDistance, | ||
List<PathDto>path | ||
) { | ||
MoveUserInfo moveUserInfo = new MoveUserInfo(); | ||
moveUserInfo.isAdmin = (participation.getUserId() == space.getAdminId()) ? true : false; | ||
moveUserInfo.userId = participation.getUserId(); | ||
moveUserInfo.userName = participation.getUserName(); | ||
moveUserInfo.transportationType = participation.getTransportation(); | ||
moveUserInfo.totalTime = totalTime; | ||
moveUserInfo.totalDistance = totalDistance; | ||
moveUserInfo.path = path; | ||
moveUserInfo.payment = 0; | ||
return moveUserInfo; | ||
} | ||
} |
This file contains 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 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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/moim/backend/domain/space/response/TmapWalkPathResponse.java
This file contains 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,49 @@ | ||
package com.moim.backend.domain.space.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class TmapWalkPathResponse { | ||
public List<Feature> features; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Feature { | ||
public Geometry geometry; | ||
public Properties properties; | ||
} | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Geometry { | ||
public String type; | ||
public String coordinates; | ||
} | ||
|
||
// Geometry 타입에 따라 시간이나 거리를 넘겨줄 때의 키 값이 달라짐 | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Properties { | ||
private long totalDistance; // 단위: m. Geometry 타입이 "Point"일 때 | ||
private long totalTime; // 단위: 초. Geometry 타입이 "Point"일 때 | ||
private long distance; // 단위: m. Geometry 타입이 "LineString"일 때 | ||
private long time; // 단위: 초. Geometry 타입이 "LineString"일 때 | ||
|
||
public long getTotalTime() { | ||
return totalTime + time; | ||
} | ||
|
||
public long getTotalDistance() { | ||
return totalDistance + distance; | ||
} | ||
} | ||
} |
Oops, something went wrong.