diff --git a/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathFavoritesTimeUseCaseIn.java b/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathFavoritesTimeUseCaseIn.java new file mode 100644 index 00000000..72b82bcf --- /dev/null +++ b/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathFavoritesTimeUseCaseIn.java @@ -0,0 +1,19 @@ +package com.walking.api.domain.path.dto; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Getter +@ToString +@EqualsAndHashCode +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +public class CalculatePathFavoritesTimeUseCaseIn { + private Long favoritesPathId; +} diff --git a/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathFavoritesTimeUseCaseOut.java b/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathFavoritesTimeUseCaseOut.java new file mode 100644 index 00000000..cf6a8b3a --- /dev/null +++ b/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathFavoritesTimeUseCaseOut.java @@ -0,0 +1,33 @@ +package com.walking.api.domain.path.dto; + +import com.walking.api.domain.traffic.dto.detail.PointDetail; +import com.walking.api.domain.traffic.dto.detail.TrafficDetail; +import java.time.LocalDateTime; +import java.util.List; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Getter +@ToString +@EqualsAndHashCode +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +public class CalculatePathFavoritesTimeUseCaseOut { + private LocalDateTime nowTime; + private Integer totalTime; + private Integer trafficCount; + private List departureTimes; + private Integer timeToFirstTraffic; + private Integer totalDistance; + private PointDetail startPoint; + private PointDetail endPoint; + private List traffics; + private List trafficIdsInPath; + private List paths; +} diff --git a/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathTimeUseCaseIn.java b/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathTimeUseCaseIn.java new file mode 100644 index 00000000..7c7d655c --- /dev/null +++ b/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathTimeUseCaseIn.java @@ -0,0 +1,22 @@ +package com.walking.api.domain.path.dto; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Getter +@ToString +@EqualsAndHashCode +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +public class CalculatePathTimeUseCaseIn { + private Double startLat; + private Double startLng; + private Double endLat; + private Double endLng; +} diff --git a/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathTimeUseCaseOut.java b/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathTimeUseCaseOut.java new file mode 100644 index 00000000..663b1016 --- /dev/null +++ b/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathTimeUseCaseOut.java @@ -0,0 +1,33 @@ +package com.walking.api.domain.path.dto; + +import com.walking.api.domain.traffic.dto.detail.PointDetail; +import com.walking.api.domain.traffic.dto.detail.TrafficDetail; +import java.time.LocalDateTime; +import java.util.List; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Getter +@ToString +@EqualsAndHashCode +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +public class CalculatePathTimeUseCaseOut { + private LocalDateTime nowTime; + private Integer totalTime; + private Integer trafficCount; + private List departureTimes; + private Integer timeToFirstTraffic; + private Integer totalDistance; + private PointDetail startPoint; + private PointDetail endPoint; + private List traffics; + private List trafficIdsInPath; + private List paths; +} diff --git a/api/src/main/java/com/walking/api/domain/path/dto/DeleteFavoriteRouteUseCaseIn.java b/api/src/main/java/com/walking/api/domain/path/dto/DeleteFavoriteRouteUseCaseIn.java new file mode 100644 index 00000000..004a095c --- /dev/null +++ b/api/src/main/java/com/walking/api/domain/path/dto/DeleteFavoriteRouteUseCaseIn.java @@ -0,0 +1,20 @@ +package com.walking.api.domain.path.dto; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Getter +@ToString +@EqualsAndHashCode +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +public class DeleteFavoriteRouteUseCaseIn { + private Long memberId; + private Long pathId; +} diff --git a/api/src/main/java/com/walking/api/domain/path/dto/PathPrimaryData.java b/api/src/main/java/com/walking/api/domain/path/dto/PathPrimaryData.java deleted file mode 100644 index ee3d11d9..00000000 --- a/api/src/main/java/com/walking/api/domain/path/dto/PathPrimaryData.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.walking.api.domain.path.dto; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class PathPrimaryData { - - private Integer totalTime; - private Integer untilTrafficTime; - private Integer totalDistance; -} diff --git a/api/src/main/java/com/walking/api/domain/path/dto/ReadFavoritesPathUseCaseIn.java b/api/src/main/java/com/walking/api/domain/path/dto/ReadFavoritesPathUseCaseIn.java new file mode 100644 index 00000000..cfcf902a --- /dev/null +++ b/api/src/main/java/com/walking/api/domain/path/dto/ReadFavoritesPathUseCaseIn.java @@ -0,0 +1,26 @@ +package com.walking.api.domain.path.dto; + +import com.walking.api.web.dto.request.OrderFilter; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Getter +@ToString +@EqualsAndHashCode +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +public class ReadFavoritesPathUseCaseIn { + private Long memberId; + private String name; + private OrderFilter orderFilter; + + public boolean isOrderFiltered() { + return orderFilter != null; + } +} diff --git a/api/src/main/java/com/walking/api/domain/path/dto/ReadFavoritesPathUseCaseResponse.java b/api/src/main/java/com/walking/api/domain/path/dto/ReadFavoritesPathUseCaseOut.java similarity index 89% rename from api/src/main/java/com/walking/api/domain/path/dto/ReadFavoritesPathUseCaseResponse.java rename to api/src/main/java/com/walking/api/domain/path/dto/ReadFavoritesPathUseCaseOut.java index 3f6ecf03..f552bf72 100644 --- a/api/src/main/java/com/walking/api/domain/path/dto/ReadFavoritesPathUseCaseResponse.java +++ b/api/src/main/java/com/walking/api/domain/path/dto/ReadFavoritesPathUseCaseOut.java @@ -10,8 +10,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class ReadFavoritesPathUseCaseResponse { - +public class ReadFavoritesPathUseCaseOut { private Long id; private Point startPoint; private Point endPoint; diff --git a/api/src/main/java/com/walking/api/domain/path/dto/SavePathFavoritesUseCaseRequest.java b/api/src/main/java/com/walking/api/domain/path/dto/SavePathFavoritesUseCaseIn.java similarity index 72% rename from api/src/main/java/com/walking/api/domain/path/dto/SavePathFavoritesUseCaseRequest.java rename to api/src/main/java/com/walking/api/domain/path/dto/SavePathFavoritesUseCaseIn.java index 608c7f6e..e912f515 100644 --- a/api/src/main/java/com/walking/api/domain/path/dto/SavePathFavoritesUseCaseRequest.java +++ b/api/src/main/java/com/walking/api/domain/path/dto/SavePathFavoritesUseCaseIn.java @@ -13,13 +13,13 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class SavePathFavoritesUseCaseRequest { +public class SavePathFavoritesUseCaseIn { private Long memberId; private String name; private String startName; - private double startLat; - private double startLng; + private Double startLat; + private Double startLng; private String endName; - private double endLat; - private double endLng; + private Double endLat; + private Double endLng; } diff --git a/api/src/main/java/com/walking/api/domain/path/dto/UpdateRoutePathNameUseCaseRequest.java b/api/src/main/java/com/walking/api/domain/path/dto/UpdateRoutePathNameUseCaseIn.java similarity index 89% rename from api/src/main/java/com/walking/api/domain/path/dto/UpdateRoutePathNameUseCaseRequest.java rename to api/src/main/java/com/walking/api/domain/path/dto/UpdateRoutePathNameUseCaseIn.java index 1e9d97dc..450ff67e 100644 --- a/api/src/main/java/com/walking/api/domain/path/dto/UpdateRoutePathNameUseCaseRequest.java +++ b/api/src/main/java/com/walking/api/domain/path/dto/UpdateRoutePathNameUseCaseIn.java @@ -13,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class UpdateRoutePathNameUseCaseRequest { +public class UpdateRoutePathNameUseCaseIn { private Long memberId; private Long pathId; private String name; diff --git a/api/src/main/java/com/walking/api/domain/path/model/SearchPath.java b/api/src/main/java/com/walking/api/domain/path/model/SearchPath.java index 47eaa9ee..8400909e 100644 --- a/api/src/main/java/com/walking/api/domain/path/model/SearchPath.java +++ b/api/src/main/java/com/walking/api/domain/path/model/SearchPath.java @@ -3,10 +3,10 @@ import com.walking.api.domain.client.dto.response.TMapResponseDto; import com.walking.api.domain.client.dto.response.detail.FeatureDetail; import com.walking.api.domain.client.dto.response.detail.GeometryDetail; -import com.walking.api.domain.path.dto.PathPrimaryData; import java.util.ArrayList; import java.util.List; import lombok.AllArgsConstructor; +import lombok.Data; import org.locationtech.jts.geom.*; @AllArgsConstructor @@ -14,8 +14,16 @@ public class SearchPath { private final TMapResponseDto tMapPathData; - public PathPrimaryData extractPrimaryDataByTMap() { - return new PathPrimaryData( + @Data + @AllArgsConstructor + public static class PathPrimaryVO { + private Integer totalTime; + private Integer untilTrafficTime; + private Integer totalDistance; + } + + public PathPrimaryVO extractPrimaryDataByTMap() { + return new PathPrimaryVO( calculateTotalTime(tMapPathData), calculateUntilFirstTraffic(tMapPathData), tMapPathData.getFeatureDetails().get(0).getPropertyDetails().getTotalDistance()); diff --git a/api/src/main/java/com/walking/api/domain/path/service/RouteDetailResponseService.java b/api/src/main/java/com/walking/api/domain/path/service/CalculateRouteDetailService.java similarity index 73% rename from api/src/main/java/com/walking/api/domain/path/service/RouteDetailResponseService.java rename to api/src/main/java/com/walking/api/domain/path/service/CalculateRouteDetailService.java index 4bc1eb47..bd952c12 100644 --- a/api/src/main/java/com/walking/api/domain/path/service/RouteDetailResponseService.java +++ b/api/src/main/java/com/walking/api/domain/path/service/CalculateRouteDetailService.java @@ -1,13 +1,14 @@ package com.walking.api.domain.path.service; -import com.walking.api.domain.path.dto.CalculatePathTimeUseCaseResponse; -import com.walking.api.domain.path.dto.PathPrimaryData; -import com.walking.api.domain.path.dto.PathTrafficData; +import com.walking.api.domain.path.model.SearchPath.PathPrimaryVO; +import com.walking.api.domain.path.service.dto.CRDQuery; +import com.walking.api.domain.path.service.dto.PathTrafficVO; +import com.walking.api.domain.path.service.dto.RouteDetailVO; import com.walking.api.domain.traffic.dto.detail.PointDetail; import com.walking.api.domain.traffic.service.TrafficPredictService; -import com.walking.api.domain.traffic.service.dto.TrafficPredictServiceRequest; -import com.walking.api.domain.traffic.service.dto.TrafficPredictServiceResponse; -import com.walking.api.domain.traffic.service.model.PredictedData; +import com.walking.api.domain.traffic.service.dto.TPQuery; +import com.walking.api.domain.traffic.service.dto.TPVO; +import com.walking.api.domain.traffic.service.model.PredictedTraffic; import com.walking.api.domain.util.JsonParser; import com.walking.api.web.dto.support.TrafficDetailConverter; import com.walking.data.entity.path.TrafficDirection; @@ -29,22 +30,23 @@ @Transactional(readOnly = true) @AllArgsConstructor @Slf4j -public class RouteDetailResponseService { +public class CalculateRouteDetailService { private final TrafficPredictService trafficPredictService; - public CalculatePathTimeUseCaseResponse execute( - double startLat, - double startLng, - double endLat, - double endLng, - List traffics, - PathTrafficData pathTrafficData, - PathPrimaryData primaryData, - LineString lineString) { + public RouteDetailVO execute(CRDQuery query) { + double startLat = query.getStartLat(); + double startLng = query.getStartLng(); + double endLat = query.getEndLat(); + double endLng = query.getEndLng(); + List traffics = query.getTraffics(); + PathTrafficVO pathTrafficVo = query.getPathTrafficVo(); + PathPrimaryVO primaryData = query.getPrimaryData(); + LineString lineString = query.getLineString(); + // case 1 길에 신호등이 없는 경우 if (traffics.isEmpty()) { - return CalculatePathTimeUseCaseResponse.builder() + return RouteDetailVO.builder() .nowTime(LocalDateTime.now()) .totalTime(primaryData.getTotalTime()) .trafficCount(0) @@ -61,8 +63,8 @@ public CalculatePathTimeUseCaseResponse execute( // case 2 길에 신호등이 있는 경우 // 1. 처음 신호등의 위도 경도를 통해 교차로의 신호등 리스트를 찾는다. - if (pathTrafficData.getTrafficsInPath().isEmpty()) { - return CalculatePathTimeUseCaseResponse.builder() + if (pathTrafficVo.getTrafficsInPath().isEmpty()) { + return RouteDetailVO.builder() .nowTime(LocalDateTime.now()) .totalTime(primaryData.getTotalTime()) .trafficCount(0) @@ -79,28 +81,27 @@ public CalculatePathTimeUseCaseResponse execute( // 2. 티맵을 통해 확인한 첫번째 신호등이 어떤 방향인지 확인한다. // TrafficEntity firstTraffic = getFirstTraffic(pathTrafficData, FirstClosetTraffic); - TrafficEntity firstTraffic = pathTrafficData.getTrafficsInPath().get(0); + TrafficEntity firstTraffic = pathTrafficVo.getTrafficsInPath().get(0); // 첫 신호등에 대해 List firstTrafficId = new ArrayList<>(); firstTrafficId.add(firstTraffic.getId()); - TrafficPredictServiceResponse predictResponse = - trafficPredictService.execute( - TrafficPredictServiceRequest.builder().trafficIds(firstTrafficId).build()); + TPVO predictResponse = + trafficPredictService.execute(TPQuery.builder().trafficIds(firstTrafficId).build()); - Map firestPredictedDataMap = predictResponse.getPredictedData(); + Map firestPredictedDataMap = predictResponse.getPredictedData(); // 모든 신호등에 대해 - TrafficPredictServiceResponse allPredictResponse = + TPVO allPredictResponse = trafficPredictService.execute( - TrafficPredictServiceRequest.builder() + TPQuery.builder() .trafficIds( - pathTrafficData.getTrafficsInPath().stream() + pathTrafficVo.getTrafficsInPath().stream() .map(TrafficEntity::getId) .collect(Collectors.toList())) .build()); - Map AllPredictedDataMap = allPredictResponse.getPredictedData(); + Map AllPredictedDataMap = allPredictResponse.getPredictedData(); LocalDateTime now = LocalDateTime.now(); // 처음 내가 지나가는 신호등의 예측 출발시간 3개 @@ -112,7 +113,7 @@ public CalculatePathTimeUseCaseResponse execute( removeNullInPredictedDataMap(AllPredictedDataMap); - return CalculatePathTimeUseCaseResponse.builder() + return RouteDetailVO.builder() .nowTime(now) .totalTime(primaryData.getTotalTime()) .trafficCount(traffics.size()) @@ -123,21 +124,21 @@ public CalculatePathTimeUseCaseResponse execute( .endPoint(PointDetail.builder().lat(endLat).lng(endLng).build()) .traffics(TrafficDetailConverter.execute(new ArrayList<>(AllPredictedDataMap.values()))) .trafficIdsInPath( - pathTrafficData.getTrafficsInPath().stream() + pathTrafficVo.getTrafficsInPath().stream() .map(TrafficEntity::getId) .collect(Collectors.toList())) .paths(convertLineStringToPointDetailList(lineString)) .build(); } - private void removeNullInPredictedDataMap(Map firestPredictedDataMap) { + private void removeNullInPredictedDataMap(Map firestPredictedDataMap) { // 내가 지나는 전부를 신호등을 특정한다. - Iterator> iterator = + Iterator> iterator = firestPredictedDataMap.entrySet().iterator(); while (iterator.hasNext()) { - Map.Entry entry = iterator.next(); - PredictedData predictedData = entry.getValue(); - if (predictedData.getRedCycle().isEmpty()) { + Map.Entry entry = iterator.next(); + PredictedTraffic predictedTraffic = entry.getValue(); + if (predictedTraffic.getRedCycle().isEmpty()) { iterator.remove(); // redCycle이 null인 경우, 해당 Entry를 Map에서 제거 } } @@ -153,13 +154,13 @@ public static List convertLineStringToPointDetailList(LineString li } private List calDepartureTimes( - Map predictedDataMap, + Map predictedDataMap, TrafficEntity firstTraffic, Integer untilFirstTrafficTime, LocalDateTime now) { - PredictedData predictedData = predictedDataMap.get(firstTraffic.getId()); - predictedData.isAllPredicted(); + PredictedTraffic predictedTraffic = predictedDataMap.get(firstTraffic.getId()); + predictedTraffic.isAllPredicted(); TrafficColor currentColor; Float currentTimeLeft; @@ -167,10 +168,10 @@ private List calDepartureTimes( Float greenCycle; try { - currentColor = predictedData.getCurrentColor().orElseThrow(); - currentTimeLeft = predictedData.getCurrentTimeLeft().orElseThrow(); - redCycle = predictedData.getRedCycle().orElseThrow(); - greenCycle = predictedData.getGreenCycle().orElseThrow(); + currentColor = predictedTraffic.getCurrentColor().orElseThrow(); + currentTimeLeft = predictedTraffic.getCurrentTimeLeft().orElseThrow(); + redCycle = predictedTraffic.getRedCycle().orElseThrow(); + greenCycle = predictedTraffic.getGreenCycle().orElseThrow(); } catch (NoSuchElementException e) { return new ArrayList<>(); } diff --git a/api/src/main/java/com/walking/api/domain/path/service/ExtractPathTrafficInfoService.java b/api/src/main/java/com/walking/api/domain/path/service/ExtractPathTrafficInfoService.java index 449d76f7..b00ec6fb 100644 --- a/api/src/main/java/com/walking/api/domain/path/service/ExtractPathTrafficInfoService.java +++ b/api/src/main/java/com/walking/api/domain/path/service/ExtractPathTrafficInfoService.java @@ -1,6 +1,8 @@ package com.walking.api.domain.path.service; -import com.walking.api.domain.path.dto.PathTrafficData; +import com.walking.api.domain.path.service.dto.EPTIQuery; +import com.walking.api.domain.path.service.dto.EPTIQueryWithDirections; +import com.walking.api.domain.path.service.dto.PathTrafficVO; import com.walking.api.repository.dao.traffic.TrafficRepository; import com.walking.data.entity.path.TrafficDirection; import com.walking.data.entity.traffic.TrafficEntity; @@ -21,27 +23,30 @@ public class ExtractPathTrafficInfoService { private final TrafficRepository trafficRepository; // 신호등 좌표를 기준으로 db의 교차로의 신호등 조회 - public PathTrafficData execute(List traffics) { - PathTrafficData pathTrafficData = new PathTrafficData(); + public PathTrafficVO execute(EPTIQuery query) { + List traffics = query.getTraffics(); + PathTrafficVO pathTrafficVo = new PathTrafficVO(); for (int i = 0; i < traffics.size(); i++) { Optional closestTraffic = trafficRepository.findClosestTraffic(traffics.get(i).getX(), traffics.get(i).getY()); closestTraffic.ifPresent( - trafficEntity -> pathTrafficData.getTrafficsInPath().add(trafficEntity)); + trafficEntity -> pathTrafficVo.getTrafficsInPath().add(trafficEntity)); } - return pathTrafficData; + return pathTrafficVo; } - public PathTrafficData execute(List traffics, List trafficDirections) { - PathTrafficData pathTrafficData = new PathTrafficData(); - pathTrafficData.setTrafficDirections(trafficDirections); + public PathTrafficVO execute(EPTIQueryWithDirections query) { + List traffics = query.getTraffics(); + List trafficDirections = query.getTrafficDirections(); + PathTrafficVO pathTrafficVo = new PathTrafficVO(); + pathTrafficVo.setTrafficDirections(trafficDirections); for (int i = 0; i < traffics.size(); i++) { List closetTrafficByLocation = trafficRepository.findClosetTrafficByLocation( traffics.get(i).getX(), traffics.get(i).getY()); - pathTrafficData.getAllTraffics().addAll(closetTrafficByLocation); + pathTrafficVo.getAllTraffics().addAll(closetTrafficByLocation); } - return pathTrafficData; + return pathTrafficVo; } } diff --git a/api/src/main/java/com/walking/api/domain/path/service/dto/CRDQuery.java b/api/src/main/java/com/walking/api/domain/path/service/dto/CRDQuery.java new file mode 100644 index 00000000..c29c889b --- /dev/null +++ b/api/src/main/java/com/walking/api/domain/path/service/dto/CRDQuery.java @@ -0,0 +1,31 @@ +package com.walking.api.domain.path.service.dto; + +import com.walking.api.domain.path.model.SearchPath.PathPrimaryVO; +import java.util.List; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.locationtech.jts.geom.LineString; +import org.locationtech.jts.geom.Point; + +/** CalculateRouteDetailService 에서 사용하는 쿼리 */ +@Getter +@ToString +@EqualsAndHashCode +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +public class CRDQuery { + private double startLat; + private double startLng; + private double endLat; + private double endLng; + private List traffics; + private PathTrafficVO pathTrafficVo; + private PathPrimaryVO primaryData; + private LineString lineString; +} diff --git a/api/src/main/java/com/walking/api/domain/path/service/dto/EPTIQuery.java b/api/src/main/java/com/walking/api/domain/path/service/dto/EPTIQuery.java new file mode 100644 index 00000000..1743f13b --- /dev/null +++ b/api/src/main/java/com/walking/api/domain/path/service/dto/EPTIQuery.java @@ -0,0 +1,22 @@ +package com.walking.api.domain.path.service.dto; + +import java.util.List; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.locationtech.jts.geom.Point; + +/** ExtractPathTrafficInfoService 에서 사용하는 쿼리 */ +@Getter +@ToString +@EqualsAndHashCode +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +public class EPTIQuery { + private List traffics; +} diff --git a/api/src/main/java/com/walking/api/domain/path/service/dto/EPTIQueryWithDirections.java b/api/src/main/java/com/walking/api/domain/path/service/dto/EPTIQueryWithDirections.java new file mode 100644 index 00000000..34473547 --- /dev/null +++ b/api/src/main/java/com/walking/api/domain/path/service/dto/EPTIQueryWithDirections.java @@ -0,0 +1,24 @@ +package com.walking.api.domain.path.service.dto; + +import com.walking.data.entity.path.TrafficDirection; +import java.util.List; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.locationtech.jts.geom.Point; + +/** ExtractPathTrafficInfoService 에서 사용하는 쿼리 */ +@Getter +@ToString +@EqualsAndHashCode +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +public class EPTIQueryWithDirections { + private List traffics; + List trafficDirections; +} diff --git a/api/src/main/java/com/walking/api/domain/path/dto/PathTrafficData.java b/api/src/main/java/com/walking/api/domain/path/service/dto/PathTrafficVO.java similarity index 84% rename from api/src/main/java/com/walking/api/domain/path/dto/PathTrafficData.java rename to api/src/main/java/com/walking/api/domain/path/service/dto/PathTrafficVO.java index 0d25984a..113820ea 100644 --- a/api/src/main/java/com/walking/api/domain/path/dto/PathTrafficData.java +++ b/api/src/main/java/com/walking/api/domain/path/service/dto/PathTrafficVO.java @@ -1,4 +1,4 @@ -package com.walking.api.domain.path.dto; +package com.walking.api.domain.path.service.dto; import com.walking.data.entity.path.TrafficDirection; import com.walking.data.entity.traffic.TrafficEntity; @@ -9,7 +9,7 @@ @Data @Getter -public class PathTrafficData { +public class PathTrafficVO { private List trafficDirections = new ArrayList<>(); private List trafficsInPath = new ArrayList<>(); diff --git a/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathTimeUseCaseResponse.java b/api/src/main/java/com/walking/api/domain/path/service/dto/RouteDetailVO.java similarity index 90% rename from api/src/main/java/com/walking/api/domain/path/dto/CalculatePathTimeUseCaseResponse.java rename to api/src/main/java/com/walking/api/domain/path/service/dto/RouteDetailVO.java index 623c169f..6c98d176 100644 --- a/api/src/main/java/com/walking/api/domain/path/dto/CalculatePathTimeUseCaseResponse.java +++ b/api/src/main/java/com/walking/api/domain/path/service/dto/RouteDetailVO.java @@ -1,4 +1,4 @@ -package com.walking.api.domain.path.dto; +package com.walking.api.domain.path.service.dto; import com.walking.api.domain.traffic.dto.detail.PointDetail; import com.walking.api.domain.traffic.dto.detail.TrafficDetail; @@ -18,7 +18,7 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) @Builder -public class CalculatePathTimeUseCaseResponse { +public class RouteDetailVO { public LocalDateTime nowTime; public Integer totalTime; diff --git a/api/src/main/java/com/walking/api/domain/path/usecase/CalculatePathFavoritesTimeUseCase.java b/api/src/main/java/com/walking/api/domain/path/usecase/CalculatePathFavoritesTimeUseCase.java index c15b7034..5424c50c 100644 --- a/api/src/main/java/com/walking/api/domain/path/usecase/CalculatePathFavoritesTimeUseCase.java +++ b/api/src/main/java/com/walking/api/domain/path/usecase/CalculatePathFavoritesTimeUseCase.java @@ -1,10 +1,14 @@ package com.walking.api.domain.path.usecase; -import com.walking.api.domain.path.dto.CalculatePathTimeUseCaseResponse; -import com.walking.api.domain.path.dto.PathPrimaryData; -import com.walking.api.domain.path.dto.PathTrafficData; +import com.walking.api.domain.path.dto.CalculatePathFavoritesTimeUseCaseIn; +import com.walking.api.domain.path.dto.CalculatePathFavoritesTimeUseCaseOut; +import com.walking.api.domain.path.model.SearchPath.PathPrimaryVO; +import com.walking.api.domain.path.service.CalculateRouteDetailService; import com.walking.api.domain.path.service.ExtractPathTrafficInfoService; -import com.walking.api.domain.path.service.RouteDetailResponseService; +import com.walking.api.domain.path.service.dto.CRDQuery; +import com.walking.api.domain.path.service.dto.EPTIQueryWithDirections; +import com.walking.api.domain.path.service.dto.PathTrafficVO; +import com.walking.api.domain.path.service.dto.RouteDetailVO; import com.walking.api.repository.dao.path.PathFavoritesRepository; import com.walking.api.repository.dao.path.TrafficInPathFavoritesRepository; import com.walking.data.entity.path.PathFavoritesEntity; @@ -24,11 +28,13 @@ public class CalculatePathFavoritesTimeUseCase { private final PathFavoritesRepository pathFavoritesRepository; private final TrafficInPathFavoritesRepository trafficInPathFavoritesRepository; + private final ExtractPathTrafficInfoService extractPathTrafficInfoService; - private final RouteDetailResponseService routeDetailResponseService; + private final CalculateRouteDetailService calculateRouteDetailService; - public CalculatePathTimeUseCaseResponse execute(Long favoritesPathId) { - Optional findPath = pathFavoritesRepository.findById(favoritesPathId); + public CalculatePathFavoritesTimeUseCaseOut execute(CalculatePathFavoritesTimeUseCaseIn in) { + Optional findPath = + pathFavoritesRepository.findById(in.getFavoritesPathId()); PathFavoritesEntity pathFavorites = checkPathFavoritesEntity(findPath); @@ -42,21 +48,43 @@ public CalculatePathTimeUseCaseResponse execute(Long favoritesPathId) { trafficInPathFavorites.getTrafficTypes(); // 내가 지나는 신호등의 방향정보 List traffics = trafficInPathFavorites.getTrafficPoints(); // 내가 지나는 신호등 위치의 중간값 - PathTrafficData pathTrafficData = - extractPathTrafficInfoService.execute(traffics, trafficDirections); - - return routeDetailResponseService.execute( - pathFavorites.getStartPoint().getY(), - pathFavorites.getStartPoint().getX(), - pathFavorites.getEndPoint().getY(), - pathFavorites.getEndPoint().getX(), - traffics, - pathTrafficData, - new PathPrimaryData( - pathFavorites.getTotalTime(), - pathFavorites.getUntilFirstTrafficTime(), - pathFavorites.getTotalDistance()), - pathFavorites.getPath()); + PathTrafficVO pathTrafficVo = + extractPathTrafficInfoService.execute( + EPTIQueryWithDirections.builder() + .traffics(traffics) + .trafficDirections(trafficDirections) + .build()); + + RouteDetailVO routeDetailVo = + calculateRouteDetailService.execute( + CRDQuery.builder() + .startLat(pathFavorites.getStartPoint().getY()) + .startLng(pathFavorites.getStartPoint().getX()) + .endLat(pathFavorites.getEndPoint().getY()) + .endLng(pathFavorites.getEndPoint().getX()) + .traffics(traffics) + .pathTrafficVo(pathTrafficVo) + .primaryData( + new PathPrimaryVO( + pathFavorites.getTotalTime(), + pathFavorites.getUntilFirstTrafficTime(), + pathFavorites.getTotalDistance())) + .lineString(pathFavorites.getPath()) + .build()); + + return CalculatePathFavoritesTimeUseCaseOut.builder() + .nowTime(routeDetailVo.getNowTime()) + .totalTime(routeDetailVo.getTotalTime()) + .trafficCount(routeDetailVo.getTrafficCount()) + .departureTimes(routeDetailVo.getDepartureTimes()) + .timeToFirstTraffic(routeDetailVo.getTimeToFirstTraffic()) + .totalDistance(routeDetailVo.getTotalDistance()) + .startPoint(routeDetailVo.getStartPoint()) + .endPoint(routeDetailVo.getEndPoint()) + .traffics(routeDetailVo.getTraffics()) + .trafficIdsInPath(routeDetailVo.getTrafficIdsInPath()) + .paths(routeDetailVo.getPaths()) + .build(); } private TrafficInPathFavoritesEntity checkTrafficInPathFavoritesEntity( diff --git a/api/src/main/java/com/walking/api/domain/path/usecase/CalculatePathTimeUseCase.java b/api/src/main/java/com/walking/api/domain/path/usecase/CalculatePathTimeUseCase.java index 4603fbba..1acb64f0 100644 --- a/api/src/main/java/com/walking/api/domain/path/usecase/CalculatePathTimeUseCase.java +++ b/api/src/main/java/com/walking/api/domain/path/usecase/CalculatePathTimeUseCase.java @@ -5,12 +5,16 @@ import com.walking.api.domain.client.TMapClient; import com.walking.api.domain.client.dto.request.TMapRequestDto; import com.walking.api.domain.client.dto.response.TMapResponseDto; -import com.walking.api.domain.path.dto.CalculatePathTimeUseCaseResponse; -import com.walking.api.domain.path.dto.PathPrimaryData; -import com.walking.api.domain.path.dto.PathTrafficData; +import com.walking.api.domain.path.dto.CalculatePathTimeUseCaseIn; +import com.walking.api.domain.path.dto.CalculatePathTimeUseCaseOut; import com.walking.api.domain.path.model.SearchPath; +import com.walking.api.domain.path.model.SearchPath.PathPrimaryVO; +import com.walking.api.domain.path.service.CalculateRouteDetailService; import com.walking.api.domain.path.service.ExtractPathTrafficInfoService; -import com.walking.api.domain.path.service.RouteDetailResponseService; +import com.walking.api.domain.path.service.dto.CRDQuery; +import com.walking.api.domain.path.service.dto.EPTIQuery; +import com.walking.api.domain.path.service.dto.PathTrafficVO; +import com.walking.api.domain.path.service.dto.RouteDetailVO; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -27,24 +31,49 @@ public class CalculatePathTimeUseCase { private final TMapClient tMapClient; private final ExtractPathTrafficInfoService extractPathTrafficInfoService; - private final RouteDetailResponseService routeDetailResponseService; + private final CalculateRouteDetailService calculateRouteDetailService; - public CalculatePathTimeUseCaseResponse execute( - double startLat, double startLng, double endLat, double endLng) { - - TMapResponseDto tMapPathData = searchPath(startLat, startLng, endLat, endLng); + public CalculatePathTimeUseCaseOut execute(CalculatePathTimeUseCaseIn in) { + TMapResponseDto tMapPathData = + searchPath(in.getStartLat(), in.getStartLng(), in.getEndLat(), in.getEndLng()); SearchPath searchPath = new SearchPath(tMapPathData); - PathPrimaryData primaryData = searchPath.extractPrimaryDataByTMap(); + PathPrimaryVO primaryData = searchPath.extractPrimaryDataByTMap(); + // LineString 추출 LineString lineString = searchPath.extractLineString(); // 신호등 중간값 좌표 추출 List traffics = searchPath.extractAllTrafficPoints(); - PathTrafficData pathTrafficData = extractPathTrafficInfoService.execute(traffics); + PathTrafficVO pathTrafficVo = + extractPathTrafficInfoService.execute(EPTIQuery.builder().traffics(traffics).build()); + + RouteDetailVO routeDetailVO = + calculateRouteDetailService.execute( + CRDQuery.builder() + .startLat(in.getStartLat()) + .startLng(in.getStartLng()) + .endLat(in.getEndLat()) + .endLng(in.getEndLng()) + .traffics(traffics) + .pathTrafficVo(pathTrafficVo) + .primaryData(primaryData) + .lineString(lineString) + .build()); - return routeDetailResponseService.execute( - startLat, startLng, endLat, endLng, traffics, pathTrafficData, primaryData, lineString); + return CalculatePathTimeUseCaseOut.builder() + .nowTime(routeDetailVO.getNowTime()) + .totalTime(routeDetailVO.getTotalTime()) + .trafficCount(routeDetailVO.getTrafficCount()) + .departureTimes(routeDetailVO.getDepartureTimes()) + .timeToFirstTraffic(routeDetailVO.getTimeToFirstTraffic()) + .totalDistance(routeDetailVO.getTotalDistance()) + .startPoint(routeDetailVO.getStartPoint()) + .endPoint(routeDetailVO.getEndPoint()) + .traffics(routeDetailVO.getTraffics()) + .trafficIdsInPath(routeDetailVO.getTrafficIdsInPath()) + .paths(routeDetailVO.getPaths()) + .build(); } // todo service 클래스로 분리 diff --git a/api/src/main/java/com/walking/api/domain/path/usecase/DeleteFavoriteRouteUseCase.java b/api/src/main/java/com/walking/api/domain/path/usecase/DeleteFavoriteRouteUseCase.java index 68247fc9..1d4ec6b0 100644 --- a/api/src/main/java/com/walking/api/domain/path/usecase/DeleteFavoriteRouteUseCase.java +++ b/api/src/main/java/com/walking/api/domain/path/usecase/DeleteFavoriteRouteUseCase.java @@ -1,5 +1,6 @@ package com.walking.api.domain.path.usecase; +import com.walking.api.domain.path.dto.DeleteFavoriteRouteUseCaseIn; import com.walking.api.repository.dao.path.PathFavoritesRepository; import com.walking.data.entity.member.MemberEntity; import lombok.RequiredArgsConstructor; @@ -15,8 +16,8 @@ public class DeleteFavoriteRouteUseCase { private final PathFavoritesRepository pathFavoritesRepository; - public void execute(Long memberId, Long pathId) { + public void execute(DeleteFavoriteRouteUseCaseIn in) { pathFavoritesRepository.deleteByMemberFkAndId( - MemberEntity.builder().id(memberId).build(), pathId); + MemberEntity.builder().id(in.getMemberId()).build(), in.getPathId()); } } diff --git a/api/src/main/java/com/walking/api/domain/path/usecase/ReadFavoritesPathUseCase.java b/api/src/main/java/com/walking/api/domain/path/usecase/ReadFavoritesPathUseCase.java index f4c672bb..0b6fe331 100644 --- a/api/src/main/java/com/walking/api/domain/path/usecase/ReadFavoritesPathUseCase.java +++ b/api/src/main/java/com/walking/api/domain/path/usecase/ReadFavoritesPathUseCase.java @@ -1,6 +1,7 @@ package com.walking.api.domain.path.usecase; -import com.walking.api.domain.path.dto.ReadFavoritesPathUseCaseResponse; +import com.walking.api.domain.path.dto.ReadFavoritesPathUseCaseIn; +import com.walking.api.domain.path.dto.ReadFavoritesPathUseCaseOut; import com.walking.api.repository.dao.dto.response.PathFavoritesVo; import com.walking.api.repository.dao.member.MemberRepository; import com.walking.api.repository.dao.path.PathFavoritesRepository; @@ -25,15 +26,18 @@ public class ReadFavoritesPathUseCase { // todo refactor service 클래스로 분리 private final MemberRepository memberRepository; - public List execute(Long memberId, String name) { + public List execute(ReadFavoritesPathUseCaseIn in) { + if (in.isOrderFiltered()) { + return doExecute(in.getMemberId(), in.getOrderFilter()); + } List pathFavorites = pathFavoritesRepository.findPathFavoritesByMemberFkAndFilterName( - memberRepository.findById(memberId).get(), name); + memberRepository.findById(in.getMemberId()).get(), in.getName()); return mappedFavoritesPathOrder(pathFavorites); } - public List execute(Long memberId, OrderFilter orderFilter) { + private List doExecute(Long memberId, OrderFilter orderFilter) { if (orderFilter == OrderFilter.NAME) { return mappedFavoritesPathOrder( pathFavoritesRepository.findPathFavoritesByMemberFkOrderByName( @@ -54,14 +58,14 @@ public List execute(Long memberId, OrderFilter throw new IllegalArgumentException("잘못된 OrderFilter입니다."); } - private List mappedFavoritesPathOrder( + private List mappedFavoritesPathOrder( List pathFavorites) { // 인덱스를 위한 AtomicInteger AtomicInteger index = new AtomicInteger(); return pathFavorites.stream() .map( vo -> - ReadFavoritesPathUseCaseResponse.builder() + ReadFavoritesPathUseCaseOut.builder() .id(vo.getId()) .startPoint((Point) vo.getStartPoint()) .endPoint((Point) vo.getEndPoint()) diff --git a/api/src/main/java/com/walking/api/domain/path/usecase/SavePathFavoritesUseCase.java b/api/src/main/java/com/walking/api/domain/path/usecase/SavePathFavoritesUseCase.java index 1fef093e..aa050bed 100644 --- a/api/src/main/java/com/walking/api/domain/path/usecase/SavePathFavoritesUseCase.java +++ b/api/src/main/java/com/walking/api/domain/path/usecase/SavePathFavoritesUseCase.java @@ -5,11 +5,12 @@ import com.walking.api.domain.client.TMapClient; import com.walking.api.domain.client.dto.request.TMapRequestDto; import com.walking.api.domain.client.dto.response.TMapResponseDto; -import com.walking.api.domain.path.dto.PathPrimaryData; -import com.walking.api.domain.path.dto.PathTrafficData; -import com.walking.api.domain.path.dto.SavePathFavoritesUseCaseRequest; +import com.walking.api.domain.path.dto.SavePathFavoritesUseCaseIn; import com.walking.api.domain.path.model.SearchPath; +import com.walking.api.domain.path.model.SearchPath.PathPrimaryVO; import com.walking.api.domain.path.service.ExtractPathTrafficInfoService; +import com.walking.api.domain.path.service.dto.EPTIQuery; +import com.walking.api.domain.path.service.dto.PathTrafficVO; import com.walking.api.repository.dao.path.PathFavoritesRepository; import com.walking.api.repository.dao.path.TrafficInPathFavoritesRepository; import com.walking.data.entity.member.MemberEntity; @@ -31,13 +32,12 @@ public class SavePathFavoritesUseCase { private final TMapClient tMapClient; private final ExtractPathTrafficInfoService extractPathTrafficInfoService; - public void execute(SavePathFavoritesUseCaseRequest request) { + public void execute(SavePathFavoritesUseCaseIn in) { TMapResponseDto tMapPathData = - getTMapPathData( - request.getStartLat(), request.getStartLng(), request.getEndLat(), request.getEndLng()); + getTMapPathData(in.getStartLat(), in.getStartLng(), in.getEndLat(), in.getEndLng()); SearchPath searchPath = new SearchPath(tMapPathData); - PathPrimaryData primaryData = searchPath.extractPrimaryDataByTMap(); + PathPrimaryVO primaryData = searchPath.extractPrimaryDataByTMap(); // 신호등 중간값 좌표 추출 List traffics = searchPath.extractAllTrafficPoints(); @@ -45,21 +45,22 @@ public void execute(SavePathFavoritesUseCaseRequest request) { // LineString 추출 LineString lineString = searchPath.extractLineString(); - PathTrafficData pathTrafficData = extractPathTrafficInfoService.execute(traffics); + PathTrafficVO pathTrafficVo = + extractPathTrafficInfoService.execute(EPTIQuery.builder().traffics(traffics).build()); // 저장 savePathFavoritesAndTrafficInFavorites( - request, traffics, pathTrafficData.getTrafficDirections(), lineString, primaryData); + in, traffics, pathTrafficVo.getTrafficDirections(), lineString, primaryData); } // todo 다른 객체로 분리 @Transactional(readOnly = false) public void savePathFavoritesAndTrafficInFavorites( - SavePathFavoritesUseCaseRequest request, + SavePathFavoritesUseCaseIn request, List traffics, List trafficDirections, LineString lineString, - PathPrimaryData primaryData) { + PathPrimaryVO primaryData) { PathFavoritesEntity savedPathFavorites = pathFavoritesRepository.save( PathFavoritesEntity.builder() diff --git a/api/src/main/java/com/walking/api/domain/path/usecase/UpdateRoutePathNameUseCase.java b/api/src/main/java/com/walking/api/domain/path/usecase/UpdateRoutePathNameUseCase.java index d984f542..729d0c34 100644 --- a/api/src/main/java/com/walking/api/domain/path/usecase/UpdateRoutePathNameUseCase.java +++ b/api/src/main/java/com/walking/api/domain/path/usecase/UpdateRoutePathNameUseCase.java @@ -1,6 +1,6 @@ package com.walking.api.domain.path.usecase; -import com.walking.api.domain.path.dto.UpdateRoutePathNameUseCaseRequest; +import com.walking.api.domain.path.dto.UpdateRoutePathNameUseCaseIn; import com.walking.api.repository.dao.path.PathFavoritesRepository; import com.walking.data.entity.member.MemberEntity; import lombok.RequiredArgsConstructor; @@ -17,12 +17,12 @@ public class UpdateRoutePathNameUseCase { private final PathFavoritesRepository pathFavoritesRepository; @Transactional - public void execute(UpdateRoutePathNameUseCaseRequest request) { + public void execute(UpdateRoutePathNameUseCaseIn in) { pathFavoritesRepository.updatePathName( - MemberEntity.builder().id(request.getMemberId()).build(), - request.getPathId(), - request.getName(), - request.getStartAlias(), - request.getEndAlias()); + MemberEntity.builder().id(in.getMemberId()).build(), + in.getPathId(), + in.getName(), + in.getStartAlias(), + in.getEndAlias()); } } diff --git a/api/src/main/java/com/walking/api/domain/traffic/dto/AddFavoriteTrafficUseCaseRequest.java b/api/src/main/java/com/walking/api/domain/traffic/dto/AddFavoriteTrafficUseCaseIn.java similarity index 88% rename from api/src/main/java/com/walking/api/domain/traffic/dto/AddFavoriteTrafficUseCaseRequest.java rename to api/src/main/java/com/walking/api/domain/traffic/dto/AddFavoriteTrafficUseCaseIn.java index 8cd9d2d5..70b4e4ef 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/dto/AddFavoriteTrafficUseCaseRequest.java +++ b/api/src/main/java/com/walking/api/domain/traffic/dto/AddFavoriteTrafficUseCaseIn.java @@ -13,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class AddFavoriteTrafficUseCaseRequest { +public class AddFavoriteTrafficUseCaseIn { private Long memberId; private Long trafficId; diff --git a/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseRequest.java b/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseIn.java similarity index 86% rename from api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseRequest.java rename to api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseIn.java index 3e896755..9c2ea30a 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseRequest.java +++ b/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseIn.java @@ -13,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder(toBuilder = true) -public class BrowseFavoriteTrafficsUseCaseRequest { +public class BrowseFavoriteTrafficsUseCaseIn { private Long memberId; } diff --git a/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseResponse.java b/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseOut.java similarity index 90% rename from api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseResponse.java rename to api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseOut.java index 6db857f7..0167ed9a 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseResponse.java +++ b/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseFavoriteTrafficsUseCaseOut.java @@ -16,7 +16,7 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) @Builder -public class BrowseFavoriteTrafficsUseCaseResponse { +public class BrowseFavoriteTrafficsUseCaseOut { private List traffics; } diff --git a/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseRequest.java b/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseIn.java similarity index 91% rename from api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseRequest.java rename to api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseIn.java index 37faca76..7f21128b 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseRequest.java +++ b/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseIn.java @@ -13,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder(toBuilder = true) -public class BrowseTrafficsUseCaseRequest { +public class BrowseTrafficsUseCaseIn { private Long trafficId; @Builder.Default private Long memberId = -1L; diff --git a/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseResponse.java b/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseOut.java similarity index 66% rename from api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseResponse.java rename to api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseOut.java index eeb0156d..937fbcac 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseResponse.java +++ b/api/src/main/java/com/walking/api/domain/traffic/dto/BrowseTrafficsUseCaseOut.java @@ -2,7 +2,7 @@ import com.walking.api.domain.traffic.dto.detail.FavoriteTrafficDetail; import com.walking.api.domain.traffic.dto.detail.TrafficDetail; -import com.walking.api.domain.traffic.service.model.PredictedData; +import com.walking.api.domain.traffic.service.model.PredictedTraffic; import com.walking.api.web.dto.support.TrafficDetailConverter; import java.util.Optional; import lombok.AccessLevel; @@ -19,12 +19,12 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) @Builder -public class BrowseTrafficsUseCaseResponse { +public class BrowseTrafficsUseCaseOut { private TrafficDetail traffic; - public BrowseTrafficsUseCaseResponse( - PredictedData predictedData, Optional favoriteTrafficDetail) { - this.traffic = TrafficDetailConverter.execute(predictedData, favoriteTrafficDetail); + public BrowseTrafficsUseCaseOut( + PredictedTraffic predictedTraffic, Optional favoriteTrafficDetail) { + this.traffic = TrafficDetailConverter.execute(predictedTraffic, favoriteTrafficDetail); } } diff --git a/api/src/main/java/com/walking/api/domain/traffic/dto/DeleteFavoriteTrafficUseCaseRequest.java b/api/src/main/java/com/walking/api/domain/traffic/dto/DeleteFavoriteTrafficUseCaseIn.java similarity index 87% rename from api/src/main/java/com/walking/api/domain/traffic/dto/DeleteFavoriteTrafficUseCaseRequest.java rename to api/src/main/java/com/walking/api/domain/traffic/dto/DeleteFavoriteTrafficUseCaseIn.java index a8606294..964ebb21 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/dto/DeleteFavoriteTrafficUseCaseRequest.java +++ b/api/src/main/java/com/walking/api/domain/traffic/dto/DeleteFavoriteTrafficUseCaseIn.java @@ -13,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class DeleteFavoriteTrafficUseCaseRequest { +public class DeleteFavoriteTrafficUseCaseIn { private Long favoriteTrafficId; private Long memberId; diff --git a/api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseRequest.java b/api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseIn.java similarity index 89% rename from api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseRequest.java rename to api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseIn.java index 1dd68d96..594c0e0b 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseRequest.java +++ b/api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseIn.java @@ -13,7 +13,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class SearchTrafficsUseCaseRequest { +public class SearchTrafficsUseCaseIn { private Float vblLng; private Float vblLat; private Float vtrLng; diff --git a/api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseResponse.java b/api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseOut.java similarity index 92% rename from api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseResponse.java rename to api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseOut.java index 5fa418a9..aa3391c3 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseResponse.java +++ b/api/src/main/java/com/walking/api/domain/traffic/dto/SearchTrafficsUseCaseOut.java @@ -16,7 +16,7 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) @Builder -public class SearchTrafficsUseCaseResponse { +public class SearchTrafficsUseCaseOut { private List traffics; } diff --git a/api/src/main/java/com/walking/api/domain/traffic/dto/UpdateFavoriteTrafficUseCaseRequest.java b/api/src/main/java/com/walking/api/domain/traffic/dto/UpdateFavoriteTrafficUseCaseIn.java similarity index 90% rename from api/src/main/java/com/walking/api/domain/traffic/dto/UpdateFavoriteTrafficUseCaseRequest.java rename to api/src/main/java/com/walking/api/domain/traffic/dto/UpdateFavoriteTrafficUseCaseIn.java index 1a862d43..8a282737 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/dto/UpdateFavoriteTrafficUseCaseRequest.java +++ b/api/src/main/java/com/walking/api/domain/traffic/dto/UpdateFavoriteTrafficUseCaseIn.java @@ -14,7 +14,7 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) @Builder -public class UpdateFavoriteTrafficUseCaseRequest { +public class UpdateFavoriteTrafficUseCaseIn { private Long memberId; private Long favoriteTrafficId; diff --git a/api/src/main/java/com/walking/api/domain/traffic/service/TrafficPredictService.java b/api/src/main/java/com/walking/api/domain/traffic/service/TrafficPredictService.java index 91b6f278..01d50e04 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/service/TrafficPredictService.java +++ b/api/src/main/java/com/walking/api/domain/traffic/service/TrafficPredictService.java @@ -1,8 +1,8 @@ package com.walking.api.domain.traffic.service; -import com.walking.api.domain.traffic.service.dto.CurrentDetailsResponse; -import com.walking.api.domain.traffic.service.dto.TrafficPredictServiceRequest; -import com.walking.api.domain.traffic.service.dto.TrafficPredictServiceResponse; +import com.walking.api.domain.traffic.service.dto.CurrentDetailsVO; +import com.walking.api.domain.traffic.service.dto.TPQuery; +import com.walking.api.domain.traffic.service.dto.TPVO; import com.walking.api.domain.traffic.service.predictor.TrafficCurrentDetailPredictor; import com.walking.api.domain.traffic.service.predictor.TrafficCyclePredictor; import java.util.List; @@ -21,17 +21,15 @@ public class TrafficPredictService { private final TrafficCurrentDetailPredictor trafficCurrentDetailPredictor; @Transactional(readOnly = true) - public TrafficPredictServiceResponse execute(TrafficPredictServiceRequest requestDto) { + public TPVO execute(TPQuery requestDto) { final List trafficIds = requestDto.getTrafficIds(); - CurrentDetailsResponse currentTrafficDetails = + CurrentDetailsVO currentTrafficDetails = trafficCurrentDetailPredictor.execute(trafficCyclePredictor, trafficIds); - return TrafficPredictServiceResponse.builder() - .predictedData(currentTrafficDetails.getCurrentDetails()) - .build(); + return TPVO.builder().predictedData(currentTrafficDetails.getCurrentDetails()).build(); } - public TrafficPredictServiceResponse execute(List trafficIds) { - return execute(TrafficPredictServiceRequest.builder().trafficIds(trafficIds).build()); + public TPVO execute(List trafficIds) { + return execute(TPQuery.builder().trafficIds(trafficIds).build()); } } diff --git a/api/src/main/java/com/walking/api/domain/traffic/service/dto/CurrentDetailsResponse.java b/api/src/main/java/com/walking/api/domain/traffic/service/dto/CurrentDetailsResponse.java deleted file mode 100644 index 18363d61..00000000 --- a/api/src/main/java/com/walking/api/domain/traffic/service/dto/CurrentDetailsResponse.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.walking.api.domain.traffic.service.dto; - -import com.walking.api.domain.traffic.service.model.PredictedData; -import java.util.Map; -import lombok.Builder; -import lombok.Getter; - -@Getter -@Builder -public class CurrentDetailsResponse { - - Map currentDetails; -} diff --git a/api/src/main/java/com/walking/api/domain/traffic/service/dto/CurrentDetailsVO.java b/api/src/main/java/com/walking/api/domain/traffic/service/dto/CurrentDetailsVO.java new file mode 100644 index 00000000..721e7768 --- /dev/null +++ b/api/src/main/java/com/walking/api/domain/traffic/service/dto/CurrentDetailsVO.java @@ -0,0 +1,13 @@ +package com.walking.api.domain.traffic.service.dto; + +import com.walking.api.domain.traffic.service.model.PredictedTraffic; +import java.util.Map; +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class CurrentDetailsVO { + + Map currentDetails; +} diff --git a/api/src/main/java/com/walking/api/domain/traffic/service/dto/TrafficPredictServiceRequest.java b/api/src/main/java/com/walking/api/domain/traffic/service/dto/TPQuery.java similarity index 68% rename from api/src/main/java/com/walking/api/domain/traffic/service/dto/TrafficPredictServiceRequest.java rename to api/src/main/java/com/walking/api/domain/traffic/service/dto/TPQuery.java index ab29b837..08ff8f84 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/service/dto/TrafficPredictServiceRequest.java +++ b/api/src/main/java/com/walking/api/domain/traffic/service/dto/TPQuery.java @@ -4,8 +4,9 @@ import lombok.Builder; import lombok.Getter; +/** TrafficPredictService 에서 사용하는 쿼리 */ @Getter @Builder -public class TrafficPredictServiceRequest { +public class TPQuery { private List trafficIds; } diff --git a/api/src/main/java/com/walking/api/domain/traffic/service/dto/TrafficPredictServiceResponse.java b/api/src/main/java/com/walking/api/domain/traffic/service/dto/TPVO.java similarity index 51% rename from api/src/main/java/com/walking/api/domain/traffic/service/dto/TrafficPredictServiceResponse.java rename to api/src/main/java/com/walking/api/domain/traffic/service/dto/TPVO.java index 99439163..51f8b264 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/service/dto/TrafficPredictServiceResponse.java +++ b/api/src/main/java/com/walking/api/domain/traffic/service/dto/TPVO.java @@ -1,14 +1,15 @@ package com.walking.api.domain.traffic.service.dto; -import com.walking.api.domain.traffic.service.model.PredictedData; +import com.walking.api.domain.traffic.service.model.PredictedTraffic; import java.util.Map; import lombok.Builder; import lombok.Getter; +/** TrafficPredictService 에서 사용하는 VO */ @Getter @Builder -public class TrafficPredictServiceResponse { +public class TPVO { /** Key: 신호등 아이디, Value: 예측된 데이터 */ - private Map predictedData; + private Map predictedData; } diff --git a/api/src/main/java/com/walking/api/domain/traffic/service/model/PredictedData.java b/api/src/main/java/com/walking/api/domain/traffic/service/model/PredictedTraffic.java similarity index 97% rename from api/src/main/java/com/walking/api/domain/traffic/service/model/PredictedData.java rename to api/src/main/java/com/walking/api/domain/traffic/service/model/PredictedTraffic.java index f9bb21da..8051f261 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/service/model/PredictedData.java +++ b/api/src/main/java/com/walking/api/domain/traffic/service/model/PredictedTraffic.java @@ -12,7 +12,7 @@ @Getter @AllArgsConstructor @ToString -public class PredictedData { +public class PredictedTraffic { private TrafficEntity traffic; private Float redCycle; @@ -20,7 +20,7 @@ public class PredictedData { private TrafficColor currentColor; // 현재 신호 색상 private Float currentTimeLeft; // 현재 신호 잔여시간 - public PredictedData(TrafficEntity traffic) { + public PredictedTraffic(TrafficEntity traffic) { this.traffic = traffic; redCycle = null; greenCycle = null; diff --git a/api/src/main/java/com/walking/api/domain/traffic/service/predictor/TrafficCurrentDetailPredictor.java b/api/src/main/java/com/walking/api/domain/traffic/service/predictor/TrafficCurrentDetailPredictor.java index 1316250a..71fbdc42 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/service/predictor/TrafficCurrentDetailPredictor.java +++ b/api/src/main/java/com/walking/api/domain/traffic/service/predictor/TrafficCurrentDetailPredictor.java @@ -1,7 +1,7 @@ package com.walking.api.domain.traffic.service.predictor; -import com.walking.api.domain.traffic.service.dto.CurrentDetailsResponse; -import com.walking.api.domain.traffic.service.model.PredictedData; +import com.walking.api.domain.traffic.service.dto.CurrentDetailsVO; +import com.walking.api.domain.traffic.service.model.PredictedTraffic; import com.walking.api.domain.util.OffsetDateTimeCalculator; import com.walking.api.repository.dao.traffic.TrafficDetailRepository; import com.walking.data.entity.traffic.TrafficDetailEntity; @@ -25,12 +25,12 @@ public class TrafficCurrentDetailPredictor { private final TrafficDetailRepository trafficDetailRepository; @Transactional(readOnly = true) - public CurrentDetailsResponse execute( + public CurrentDetailsVO execute( TrafficCyclePredictor trafficCyclePredictor, List trafficIds) { return doExecute(trafficCyclePredictor.execute(trafficIds)); } - CurrentDetailsResponse doExecute(Map predictedMap) { + CurrentDetailsVO doExecute(Map predictedMap) { Set trafficIdSet = predictedMap.keySet(); List trafficIds = new ArrayList<>(trafficIdSet); @@ -41,8 +41,8 @@ CurrentDetailsResponse doExecute(Map predictedMap) { OffsetDateTime now = OffsetDateTime.now(); for (Long id : trafficIds) { - PredictedData predictedData = predictedMap.get(id); - if (!predictedData.isPredictCycleSuccessful()) { + PredictedTraffic predictedTraffic = predictedMap.get(id); + if (!predictedTraffic.isPredictCycleSuccessful()) { continue; } @@ -51,9 +51,9 @@ CurrentDetailsResponse doExecute(Map predictedMap) { float differenceInSeconds = OffsetDateTimeCalculator.getDifferenceInSeconds(trafficDetail.getTimeLeftRegDt(), now); TrafficColor currentColor = trafficDetail.getColor(); - updatePredictData(predictedData, currentColor, timeLeft, differenceInSeconds); + updatePredictData(predictedTraffic, currentColor, timeLeft, differenceInSeconds); } - return CurrentDetailsResponse.builder().currentDetails(predictedMap).build(); + return CurrentDetailsVO.builder().currentDetails(predictedMap).build(); } private Map mappedTrafficDetailByTrafficId( @@ -67,7 +67,7 @@ private Map mappedTrafficDetailByTrafficId( /** 하나의 신호등에 대하여 현재 신호 색상과 잔여시간을 예측하는 작업을 수행 */ private void updatePredictData( - PredictedData predictedData, + PredictedTraffic predictedTraffic, TrafficColor currentColor, float timeLeft, float differenceInSeconds) { @@ -75,15 +75,15 @@ private void updatePredictData( while (differenceInSeconds >= 0) { if (currentColor.isRed()) { currentColor = TrafficColor.GREEN; - Float cycleOfNextColor = predictedData.getCycleByColor(TrafficColor.GREEN); + Float cycleOfNextColor = predictedTraffic.getCycleByColor(TrafficColor.GREEN); differenceInSeconds -= cycleOfNextColor; } else { currentColor = TrafficColor.RED; - Float cycleOfNextColor = predictedData.getCycleByColor(TrafficColor.RED); + Float cycleOfNextColor = predictedTraffic.getCycleByColor(TrafficColor.RED); differenceInSeconds -= cycleOfNextColor; } } - predictedData.updateCurrentColor(currentColor); - predictedData.updateCurrentTimeLeft(Math.abs(differenceInSeconds)); + predictedTraffic.updateCurrentColor(currentColor); + predictedTraffic.updateCurrentTimeLeft(Math.abs(differenceInSeconds)); } } diff --git a/api/src/main/java/com/walking/api/domain/traffic/service/predictor/TrafficCyclePredictor.java b/api/src/main/java/com/walking/api/domain/traffic/service/predictor/TrafficCyclePredictor.java index 658cb19a..1c31c849 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/service/predictor/TrafficCyclePredictor.java +++ b/api/src/main/java/com/walking/api/domain/traffic/service/predictor/TrafficCyclePredictor.java @@ -1,6 +1,6 @@ package com.walking.api.domain.traffic.service.predictor; -import com.walking.api.domain.traffic.service.model.PredictedData; +import com.walking.api.domain.traffic.service.model.PredictedTraffic; import com.walking.api.domain.traffic.service.model.RecentTrafficDetails; import com.walking.api.repository.dao.traffic.TrafficDetailRepository; import com.walking.api.repository.dao.traffic.TrafficRepository; @@ -28,10 +28,10 @@ public class TrafficCyclePredictor { private final TrafficDetailRepository trafficDetailRepository; @Transactional(readOnly = true) - public Map execute(List trafficIds) { - Map trafficPredictTargets = + public Map execute(List trafficIds) { + Map trafficPredictTargets = trafficRepository.findAllInIds(trafficIds).stream() - .collect(Collectors.toMap(TrafficEntity::getId, PredictedData::new)); + .collect(Collectors.toMap(TrafficEntity::getId, PredictedTraffic::new)); return doPredict(trafficPredictTargets); } @@ -39,7 +39,7 @@ public Map execute(List trafficIds) { * 최신 순으로 interval 개 만큼 씩 데이터를 가지고 와서 계산을 수행
* 예를 들어, interval이 5인 경우 한 번 예측을 시도할 때마다 5개의 데이터를 가져와 예측을 수행합니다. */ - private Map doPredict(Map trafficPredictTargets) { + private Map doPredict(Map trafficPredictTargets) { int tryCount = 0; int startRowNum = 0; int endRowNum = startRowNum + predictInterval; @@ -61,7 +61,7 @@ private Map doPredict(Map trafficPredi mappedUnpredictedTrafficRecentData.forEach( (id, recentTrafficDetails) -> { - PredictedData predictTarget = trafficPredictTargets.get(id); + PredictedTraffic predictTarget = trafficPredictTargets.get(id); predictTarget.predictCycle(recentTrafficDetails); }); @@ -77,7 +77,7 @@ private boolean isExceedTryCount(int searchCount) { return searchCount >= MAXIMUM_SEARCH_COUNT; } - private List updateUnpredictedTrafficKeys(Map predictTargets) { + private List updateUnpredictedTrafficKeys(Map predictTargets) { return predictTargets.entrySet().stream() .filter(entry -> !entry.getValue().isPredictCycleSuccessful()) .map(Map.Entry::getKey) diff --git a/api/src/main/java/com/walking/api/domain/traffic/usecase/AddFavoriteTrafficUseCase.java b/api/src/main/java/com/walking/api/domain/traffic/usecase/AddFavoriteTrafficUseCase.java index 324e314d..d55fa7da 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/usecase/AddFavoriteTrafficUseCase.java +++ b/api/src/main/java/com/walking/api/domain/traffic/usecase/AddFavoriteTrafficUseCase.java @@ -1,6 +1,6 @@ package com.walking.api.domain.traffic.usecase; -import com.walking.api.domain.traffic.dto.AddFavoriteTrafficUseCaseRequest; +import com.walking.api.domain.traffic.dto.AddFavoriteTrafficUseCaseIn; import com.walking.api.repository.dao.traffic.TrafficFavoritesRepository; import com.walking.data.entity.member.MemberEntity; import com.walking.data.entity.member.TrafficFavoritesEntity; @@ -18,7 +18,7 @@ public class AddFavoriteTrafficUseCase { private final TrafficFavoritesRepository trafficFavoritesRepository; @Transactional - public boolean execute(AddFavoriteTrafficUseCaseRequest request) { + public boolean execute(AddFavoriteTrafficUseCaseIn request) { TrafficFavoritesEntity entity = TrafficFavoritesEntity.builder() .memberFk(MemberEntity.builder().id(request.getMemberId()).build()) diff --git a/api/src/main/java/com/walking/api/domain/traffic/usecase/BrowseFavoriteTrafficsUseCase.java b/api/src/main/java/com/walking/api/domain/traffic/usecase/BrowseFavoriteTrafficsUseCase.java index 8040791a..5bc71143 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/usecase/BrowseFavoriteTrafficsUseCase.java +++ b/api/src/main/java/com/walking/api/domain/traffic/usecase/BrowseFavoriteTrafficsUseCase.java @@ -2,8 +2,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.walking.api.domain.traffic.dto.BrowseFavoriteTrafficsUseCaseRequest; -import com.walking.api.domain.traffic.dto.BrowseFavoriteTrafficsUseCaseResponse; +import com.walking.api.domain.traffic.dto.BrowseFavoriteTrafficsUseCaseIn; +import com.walking.api.domain.traffic.dto.BrowseFavoriteTrafficsUseCaseOut; import com.walking.api.domain.traffic.dto.detail.FavoriteTrafficDetail; import com.walking.api.domain.traffic.dto.detail.PointDetail; import com.walking.api.domain.traffic.dto.detail.TrafficDetailInfo; @@ -27,8 +27,7 @@ public class BrowseFavoriteTrafficsUseCase { private final ObjectMapper objectMapper; @Transactional - public BrowseFavoriteTrafficsUseCaseResponse execute( - BrowseFavoriteTrafficsUseCaseRequest request) { + public BrowseFavoriteTrafficsUseCaseOut execute(BrowseFavoriteTrafficsUseCaseIn request) { List trafficFavorites = trafficFavoritesRepository.findByMemberFkAndDeletedFalse( MemberEntity.builder().id(request.getMemberId()).build()); @@ -53,6 +52,6 @@ public BrowseFavoriteTrafficsUseCaseResponse execute( .build()); } - return BrowseFavoriteTrafficsUseCaseResponse.builder().traffics(details).build(); + return BrowseFavoriteTrafficsUseCaseOut.builder().traffics(details).build(); } } diff --git a/api/src/main/java/com/walking/api/domain/traffic/usecase/DeleteFavoriteTrafficUseCase.java b/api/src/main/java/com/walking/api/domain/traffic/usecase/DeleteFavoriteTrafficUseCase.java index 171f209f..e6c8b823 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/usecase/DeleteFavoriteTrafficUseCase.java +++ b/api/src/main/java/com/walking/api/domain/traffic/usecase/DeleteFavoriteTrafficUseCase.java @@ -1,6 +1,6 @@ package com.walking.api.domain.traffic.usecase; -import com.walking.api.domain.traffic.dto.DeleteFavoriteTrafficUseCaseRequest; +import com.walking.api.domain.traffic.dto.DeleteFavoriteTrafficUseCaseIn; import com.walking.api.repository.dao.traffic.TrafficFavoritesRepository; import com.walking.data.entity.member.MemberEntity; import com.walking.data.entity.member.TrafficFavoritesEntity; @@ -16,7 +16,7 @@ public class DeleteFavoriteTrafficUseCase { private final TrafficFavoritesRepository trafficFavoritesRepository; @Transactional - public boolean execute(DeleteFavoriteTrafficUseCaseRequest request) { + public boolean execute(DeleteFavoriteTrafficUseCaseIn request) { TrafficFavoritesEntity favoriteTraffic = trafficFavoritesRepository .findByIdAndMemberFkAndDeletedFalse( diff --git a/api/src/main/java/com/walking/api/domain/traffic/usecase/ReadTrafficsUseCase.java b/api/src/main/java/com/walking/api/domain/traffic/usecase/ReadTrafficsUseCase.java index 51af5cd4..196ec719 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/usecase/ReadTrafficsUseCase.java +++ b/api/src/main/java/com/walking/api/domain/traffic/usecase/ReadTrafficsUseCase.java @@ -2,14 +2,14 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.walking.api.domain.traffic.dto.BrowseTrafficsUseCaseRequest; -import com.walking.api.domain.traffic.dto.BrowseTrafficsUseCaseResponse; +import com.walking.api.domain.traffic.dto.BrowseTrafficsUseCaseIn; +import com.walking.api.domain.traffic.dto.BrowseTrafficsUseCaseOut; import com.walking.api.domain.traffic.dto.detail.FavoriteTrafficDetail; import com.walking.api.domain.traffic.dto.detail.PointDetail; import com.walking.api.domain.traffic.dto.detail.TrafficDetailInfo; import com.walking.api.domain.traffic.service.TrafficPredictService; -import com.walking.api.domain.traffic.service.dto.TrafficPredictServiceResponse; -import com.walking.api.domain.traffic.service.model.PredictedData; +import com.walking.api.domain.traffic.service.dto.TPVO; +import com.walking.api.domain.traffic.service.model.PredictedTraffic; import com.walking.api.repository.dao.traffic.TrafficFavoritesRepository; import com.walking.data.entity.member.MemberEntity; import com.walking.data.entity.member.TrafficFavoritesEntity; @@ -31,13 +31,12 @@ public class ReadTrafficsUseCase { private final TrafficPredictService trafficPredictService; - public BrowseTrafficsUseCaseResponse execute(BrowseTrafficsUseCaseRequest request) { + public BrowseTrafficsUseCaseOut execute(BrowseTrafficsUseCaseIn request) { final Long trafficId = request.getTrafficId(); final Long memberId = request.getMemberId(); - TrafficPredictServiceResponse trafficPredictServiceResponse = - trafficPredictService.execute(List.of(trafficId)); - PredictedData predictedData = trafficPredictServiceResponse.getPredictedData().get(trafficId); + TPVO trafficPredictServiceVO = trafficPredictService.execute(List.of(trafficId)); + PredictedTraffic predictedTraffic = trafficPredictServiceVO.getPredictedData().get(trafficId); Optional favoriteTrafficDetail = Optional.empty(); if (memberId != -1) { @@ -48,7 +47,7 @@ public BrowseTrafficsUseCaseResponse execute(BrowseTrafficsUseCaseRequest reques } } - return new BrowseTrafficsUseCaseResponse(predictedData, favoriteTrafficDetail); + return new BrowseTrafficsUseCaseOut(predictedTraffic, favoriteTrafficDetail); } private Optional getFavoriteTrafficDetail(Long memberId, Long trafficId) { diff --git a/api/src/main/java/com/walking/api/domain/traffic/usecase/SearchTrafficsUseCase.java b/api/src/main/java/com/walking/api/domain/traffic/usecase/SearchTrafficsUseCase.java index 0c83680d..53736bda 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/usecase/SearchTrafficsUseCase.java +++ b/api/src/main/java/com/walking/api/domain/traffic/usecase/SearchTrafficsUseCase.java @@ -1,11 +1,11 @@ package com.walking.api.domain.traffic.usecase; -import com.walking.api.domain.traffic.dto.SearchTrafficsUseCaseRequest; -import com.walking.api.domain.traffic.dto.SearchTrafficsUseCaseResponse; +import com.walking.api.domain.traffic.dto.SearchTrafficsUseCaseIn; +import com.walking.api.domain.traffic.dto.SearchTrafficsUseCaseOut; import com.walking.api.domain.traffic.dto.detail.TrafficDetail; import com.walking.api.domain.traffic.service.TrafficPredictService; -import com.walking.api.domain.traffic.service.dto.TrafficPredictServiceRequest; -import com.walking.api.domain.traffic.service.model.PredictedData; +import com.walking.api.domain.traffic.service.dto.TPQuery; +import com.walking.api.domain.traffic.service.model.PredictedTraffic; import com.walking.api.repository.dao.traffic.TrafficRepository; import com.walking.api.web.dto.support.TrafficDetailConverter; import com.walking.data.entity.BaseEntity; @@ -27,7 +27,7 @@ public class SearchTrafficsUseCase { private final TrafficPredictService trafficPredictService; @Transactional - public SearchTrafficsUseCaseResponse execute(SearchTrafficsUseCaseRequest request) { + public SearchTrafficsUseCaseOut execute(SearchTrafficsUseCaseIn request) { final Float vblLng = request.getVblLng(); final Float vblLat = request.getVblLat(); final Float vtrLng = request.getVtrLng(); @@ -38,12 +38,11 @@ public SearchTrafficsUseCaseResponse execute(SearchTrafficsUseCaseRequest reques .map(BaseEntity::getId) .collect(Collectors.toList()); - TrafficPredictServiceRequest predictRequest = - TrafficPredictServiceRequest.builder().trafficIds(inBoundsTrafficIds).build(); - List predictedData = + TPQuery predictRequest = TPQuery.builder().trafficIds(inBoundsTrafficIds).build(); + List predictedData = new ArrayList<>(trafficPredictService.execute(predictRequest).getPredictedData().values()); List trafficDetails = TrafficDetailConverter.execute(predictedData); - return SearchTrafficsUseCaseResponse.builder().traffics(trafficDetails).build(); + return SearchTrafficsUseCaseOut.builder().traffics(trafficDetails).build(); } } diff --git a/api/src/main/java/com/walking/api/domain/traffic/usecase/UpdateFavoriteTrafficUseCase.java b/api/src/main/java/com/walking/api/domain/traffic/usecase/UpdateFavoriteTrafficUseCase.java index 7189268d..858cd61f 100644 --- a/api/src/main/java/com/walking/api/domain/traffic/usecase/UpdateFavoriteTrafficUseCase.java +++ b/api/src/main/java/com/walking/api/domain/traffic/usecase/UpdateFavoriteTrafficUseCase.java @@ -1,6 +1,6 @@ package com.walking.api.domain.traffic.usecase; -import com.walking.api.domain.traffic.dto.UpdateFavoriteTrafficUseCaseRequest; +import com.walking.api.domain.traffic.dto.UpdateFavoriteTrafficUseCaseIn; import com.walking.api.repository.dao.traffic.TrafficFavoritesRepository; import com.walking.data.entity.member.TrafficFavoritesEntity; import lombok.RequiredArgsConstructor; @@ -16,7 +16,7 @@ public class UpdateFavoriteTrafficUseCase { private final TrafficFavoritesRepository trafficFavoritesRepository; @Transactional - public boolean execute(UpdateFavoriteTrafficUseCaseRequest request) { + public boolean execute(UpdateFavoriteTrafficUseCaseIn request) { TrafficFavoritesEntity favoriteTraffic = trafficFavoritesRepository .findByIdAndDeletedFalse(request.getFavoriteTrafficId()) diff --git a/api/src/main/java/com/walking/api/security/token/TokenGenerator.java b/api/src/main/java/com/walking/api/security/token/TokenGenerator.java index 9db5c657..fccf878d 100644 --- a/api/src/main/java/com/walking/api/security/token/TokenGenerator.java +++ b/api/src/main/java/com/walking/api/security/token/TokenGenerator.java @@ -10,21 +10,12 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; @Slf4j @RequiredArgsConstructor @Component -public class TokenGenerator implements ApplicationRunner { - - @Override - public void run(ApplicationArguments args) throws Exception { - log.info("TokenGenerator.run"); - String s = this.generateAccessToken(1L, List.of(Roles.ROLE_USER)); - log.info("s: {}", s); - } +public class TokenGenerator { @Value("${security.jwt.token.secretkey}") private String secretKey; diff --git a/api/src/main/java/com/walking/api/web/controller/member/MemberController.java b/api/src/main/java/com/walking/api/web/controller/member/MemberController.java index a21ab4bf..e99dd8bb 100644 --- a/api/src/main/java/com/walking/api/web/controller/member/MemberController.java +++ b/api/src/main/java/com/walking/api/web/controller/member/MemberController.java @@ -16,11 +16,16 @@ import com.walking.api.web.support.ApiResponse; import com.walking.api.web.support.ApiResponseGenerator; import com.walking.api.web.support.MessageCode; -import com.walking.member.api.dto.DeleteMemberUseCaseResponse; -import com.walking.member.api.dto.GetMemberDetailUseCaseResponse; -import com.walking.member.api.dto.GetMemberTokenDetailUseCaseResponse; -import com.walking.member.api.dto.PatchProfileImageUseCaseResponse; -import com.walking.member.api.dto.PostMemberUseCaseResponse; +import com.walking.member.api.dto.DeleteMemberUseCaseIn; +import com.walking.member.api.dto.DeleteMemberUseCaseOut; +import com.walking.member.api.dto.GetMemberDetailUseCaseIn; +import com.walking.member.api.dto.GetMemberDetailUseCaseOut; +import com.walking.member.api.dto.GetMemberTokenDetailUseCaseIn; +import com.walking.member.api.dto.GetMemberTokenDetailUseCaseOut; +import com.walking.member.api.dto.PatchProfileImageUseCaseIn; +import com.walking.member.api.dto.PatchProfileImageUseCaseOut; +import com.walking.member.api.dto.PostMemberUseCaseIn; +import com.walking.member.api.dto.PostMemberUseCaseOut; import com.walking.member.api.usecase.DeleteMemberUseCase; import com.walking.member.api.usecase.GetMemberDetailUseCase; import com.walking.member.api.usecase.GetMemberTokenDetailUseCase; @@ -62,7 +67,8 @@ public class MemberController { @PostMapping() public ApiResponse> postMember( @Valid @RequestBody PostMemberBody postMemberBody) { - PostMemberUseCaseResponse useCaseResponse = postMemberUseCase.execute(postMemberBody.getCode()); + PostMemberUseCaseOut useCaseResponse = + postMemberUseCase.execute(new PostMemberUseCaseIn(postMemberBody.getCode())); AuthToken authToken = tokenGenerator.generateAuthToken(useCaseResponse.getId(), List.of(Roles.ROLE_USER)); PostMemberResponse response = @@ -80,7 +86,8 @@ public ApiResponse> postMember( public ApiResponse> deleteMember( @AuthenticationPrincipal TokenUserDetails userDetails) { Long memberId = Long.valueOf(userDetails.getUsername()); - DeleteMemberUseCaseResponse useCaseResponse = deleteMemberUseCase.execute(memberId); + DeleteMemberUseCaseOut useCaseResponse = + deleteMemberUseCase.execute(new DeleteMemberUseCaseIn(memberId)); DeleteMemberResponse response = DeleteMemberResponse.builder() .id(useCaseResponse.getId()) @@ -93,7 +100,8 @@ public ApiResponse> deleteMember( public ApiResponse> getMember( @AuthenticationPrincipal TokenUserDetails userDetails) { Long memberId = Long.valueOf(userDetails.getUsername()); - GetMemberDetailUseCaseResponse useCaseResponse = getMemberDetailUseCase.execute(memberId); + GetMemberDetailUseCaseOut useCaseResponse = + getMemberDetailUseCase.execute(new GetMemberDetailUseCaseIn(memberId)); GetMemberResponse response = GetMemberResponse.builder() .id(useCaseResponse.getId()) @@ -110,8 +118,8 @@ public ApiResponse> refreshMemberAu tokenResolver .resolveId(memberAuthTokenBody.getRefreshToken()) .orElseThrow(() -> new IllegalArgumentException("Invalid token")); - GetMemberTokenDetailUseCaseResponse useCaseResponse = - getMemberTokenDetailUseCase.execute(memberId); + GetMemberTokenDetailUseCaseOut useCaseResponse = + getMemberTokenDetailUseCase.execute(new GetMemberTokenDetailUseCaseIn(memberId)); AuthToken authToken = tokenGenerator.generateAuthToken(useCaseResponse.getId(), List.of(Roles.ROLE_USER)); MemberTokenResponse response = @@ -130,8 +138,8 @@ public ApiResponse> patchProfileIm String suffix = patchProfileBody.getProfile().getOriginalFilename().split("\\.")[1]; File tempFile = File.createTempFile("temp_", "." + suffix); patchProfileBody.getProfile().transferTo(tempFile); - PatchProfileImageUseCaseResponse useCaseResponse = - patchProfileImageUseCase.execute(memberId, tempFile); + PatchProfileImageUseCaseOut useCaseResponse = + patchProfileImageUseCase.execute(new PatchProfileImageUseCaseIn(memberId, tempFile)); tempFile.deleteOnExit(); PatchProfileResponse response = PatchProfileResponse.builder() diff --git a/api/src/main/java/com/walking/api/web/controller/path/PathControllerV2.java b/api/src/main/java/com/walking/api/web/controller/path/PathControllerV2.java index 5b9f916c..89887bed 100644 --- a/api/src/main/java/com/walking/api/web/controller/path/PathControllerV2.java +++ b/api/src/main/java/com/walking/api/web/controller/path/PathControllerV2.java @@ -1,9 +1,14 @@ package com.walking.api.web.controller.path; -import com.walking.api.domain.path.dto.CalculatePathTimeUseCaseResponse; -import com.walking.api.domain.path.dto.ReadFavoritesPathUseCaseResponse; -import com.walking.api.domain.path.dto.SavePathFavoritesUseCaseRequest; -import com.walking.api.domain.path.dto.UpdateRoutePathNameUseCaseRequest; +import com.walking.api.domain.path.dto.CalculatePathFavoritesTimeUseCaseIn; +import com.walking.api.domain.path.dto.CalculatePathFavoritesTimeUseCaseOut; +import com.walking.api.domain.path.dto.CalculatePathTimeUseCaseIn; +import com.walking.api.domain.path.dto.CalculatePathTimeUseCaseOut; +import com.walking.api.domain.path.dto.DeleteFavoriteRouteUseCaseIn; +import com.walking.api.domain.path.dto.ReadFavoritesPathUseCaseIn; +import com.walking.api.domain.path.dto.ReadFavoritesPathUseCaseOut; +import com.walking.api.domain.path.dto.SavePathFavoritesUseCaseIn; +import com.walking.api.domain.path.dto.UpdateRoutePathNameUseCaseIn; import com.walking.api.domain.path.usecase.CalculatePathFavoritesTimeUseCase; import com.walking.api.domain.path.usecase.CalculatePathTimeUseCase; import com.walking.api.domain.path.usecase.DeleteFavoriteRouteUseCase; @@ -48,14 +53,16 @@ public class PathControllerV2 { private final DeleteFavoriteRouteUseCase deleteFavoriteRouteUseCase; @GetMapping("/detail") - public ApiResponse> detailRoute( + public ApiResponse> detailRoute( @Valid RoutePointParam routePointParam) { - CalculatePathTimeUseCaseResponse response = + CalculatePathTimeUseCaseOut response = calculatePathTimeUseCase.execute( - routePointParam.getStartLat(), - routePointParam.getStartLng(), - routePointParam.getEndLat(), - routePointParam.getEndLng()); + CalculatePathTimeUseCaseIn.builder() + .startLat(routePointParam.getStartLat()) + .startLng(routePointParam.getStartLng()) + .endLat(routePointParam.getEndLat()) + .endLng(routePointParam.getEndLng()) + .build()); return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.SUCCESS); } @@ -65,7 +72,7 @@ public ApiResponse addFavoriteRoute( @Valid @RequestBody FavoritePathBody favoritePathBody) { Long memberId = Long.valueOf(userDetails.getUsername()); savePathFavoritesUseCase.execute( - SavePathFavoritesUseCaseRequest.builder() + SavePathFavoritesUseCaseIn.builder() .memberId(memberId) .name(favoritePathBody.getName()) .startLat(favoritePathBody.getStartLat()) @@ -85,25 +92,33 @@ public ApiResponse> browseF @RequestParam(required = false) Optional name) { Long memberId = Long.valueOf(userDetails.getUsername()); if (name.isPresent()) { - List favoritesPaths = - readFavoritesPathUseCase.execute(memberId, name.get()); + List favoritesPaths = + readFavoritesPathUseCase.execute( + ReadFavoritesPathUseCaseIn.builder().memberId(memberId).name(name.get()).build()); BrowseFavoriteRouteResponse response = getFavoriteRouteResponse(favoritesPaths); return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.SUCCESS); } // todo implement: filter 기준 정렬 - List favoritesPaths = - readFavoritesPathUseCase.execute(memberId, filter); + List favoritesPaths = + readFavoritesPathUseCase.execute( + ReadFavoritesPathUseCaseIn.builder() + .memberId(memberId) + .name(name.get()) + .orderFilter(filter) + .build()); BrowseFavoriteRouteResponse response = getFavoriteRouteResponse(favoritesPaths); return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.SUCCESS); } @GetMapping("/favorite/{favoriteId}") - public ApiResponse> detailFavoriteRoute( - @AuthenticationPrincipal TokenUserDetails userDetails, - @Min(1) @PathVariable Long favoriteId) { - CalculatePathTimeUseCaseResponse response = - calculatePathFavoritesTimeUseCase.execute(favoriteId); + public ApiResponse> + detailFavoriteRoute( + @AuthenticationPrincipal TokenUserDetails userDetails, + @Min(1) @PathVariable Long favoriteId) { + CalculatePathFavoritesTimeUseCaseOut response = + calculatePathFavoritesTimeUseCase.execute( + CalculatePathFavoritesTimeUseCaseIn.builder().favoritesPathId(favoriteId).build()); return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.SUCCESS); } @@ -114,7 +129,7 @@ public ApiResponse updateFavoriteRoute( @Valid @RequestBody PatchFavoritePathNameBody pathNameBody) { Long memberId = Long.valueOf(userDetails.getUsername()); updateRoutePathNameUseCase.execute( - UpdateRoutePathNameUseCaseRequest.builder() + UpdateRoutePathNameUseCaseIn.builder() .memberId(memberId) .pathId(favoriteId) .name(pathNameBody.getName()) @@ -129,12 +144,13 @@ public ApiResponse deleteFavoriteRoute( @AuthenticationPrincipal TokenUserDetails userDetails, @Min(1) @PathVariable Long favoriteId) { Long memberId = Long.valueOf(userDetails.getUsername()); - deleteFavoriteRouteUseCase.execute(memberId, favoriteId); + deleteFavoriteRouteUseCase.execute( + DeleteFavoriteRouteUseCaseIn.builder().memberId(memberId).pathId(favoriteId).build()); return ApiResponseGenerator.success(HttpStatus.OK, MessageCode.RESOURCE_DELETED); } private BrowseFavoriteRouteResponse getFavoriteRouteResponse( - List favoritesPaths) { + List favoritesPaths) { List favoritePoints = favoritesPaths.stream() .map( diff --git a/api/src/main/java/com/walking/api/web/controller/traffic/TrafficController.java b/api/src/main/java/com/walking/api/web/controller/traffic/TrafficController.java index 3a91411b..674f109f 100644 --- a/api/src/main/java/com/walking/api/web/controller/traffic/TrafficController.java +++ b/api/src/main/java/com/walking/api/web/controller/traffic/TrafficController.java @@ -1,14 +1,14 @@ package com.walking.api.web.controller.traffic; -import com.walking.api.domain.traffic.dto.AddFavoriteTrafficUseCaseRequest; -import com.walking.api.domain.traffic.dto.BrowseFavoriteTrafficsUseCaseRequest; -import com.walking.api.domain.traffic.dto.BrowseFavoriteTrafficsUseCaseResponse; -import com.walking.api.domain.traffic.dto.BrowseTrafficsUseCaseRequest; -import com.walking.api.domain.traffic.dto.BrowseTrafficsUseCaseResponse; -import com.walking.api.domain.traffic.dto.DeleteFavoriteTrafficUseCaseRequest; -import com.walking.api.domain.traffic.dto.SearchTrafficsUseCaseRequest; -import com.walking.api.domain.traffic.dto.SearchTrafficsUseCaseResponse; -import com.walking.api.domain.traffic.dto.UpdateFavoriteTrafficUseCaseRequest; +import com.walking.api.domain.traffic.dto.AddFavoriteTrafficUseCaseIn; +import com.walking.api.domain.traffic.dto.BrowseFavoriteTrafficsUseCaseIn; +import com.walking.api.domain.traffic.dto.BrowseFavoriteTrafficsUseCaseOut; +import com.walking.api.domain.traffic.dto.BrowseTrafficsUseCaseIn; +import com.walking.api.domain.traffic.dto.BrowseTrafficsUseCaseOut; +import com.walking.api.domain.traffic.dto.DeleteFavoriteTrafficUseCaseIn; +import com.walking.api.domain.traffic.dto.SearchTrafficsUseCaseIn; +import com.walking.api.domain.traffic.dto.SearchTrafficsUseCaseOut; +import com.walking.api.domain.traffic.dto.UpdateFavoriteTrafficUseCaseIn; import com.walking.api.domain.traffic.usecase.AddFavoriteTrafficUseCase; import com.walking.api.domain.traffic.usecase.BrowseFavoriteTrafficsUseCase; import com.walking.api.domain.traffic.usecase.DeleteFavoriteTrafficUseCase; @@ -62,26 +62,26 @@ public class TrafficController { private final UpdateFavoriteTrafficUseCase updateFavoriteTrafficUseCase; @GetMapping() - public ApiResponse> searchTraffics( + public ApiResponse> searchTraffics( @Valid ViewPointParam viewPointParam) { - SearchTrafficsUseCaseRequest request = - SearchTrafficsUseCaseRequest.builder() + SearchTrafficsUseCaseIn request = + SearchTrafficsUseCaseIn.builder() .vblLng(viewPointParam.getVblLng()) .vblLat(viewPointParam.getVblLat()) .vtrLng(viewPointParam.getVtrLng()) .vtrLat(viewPointParam.getVtrLat()) .build(); - SearchTrafficsUseCaseResponse response = searchTrafficsUseCase.execute(request); + SearchTrafficsUseCaseOut response = searchTrafficsUseCase.execute(request); return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.SUCCESS); } @GetMapping("/{trafficId}") - public ApiResponse> readTraffic( + public ApiResponse> readTraffic( HttpServletRequest request, @PathVariable Long trafficId) { - BrowseTrafficsUseCaseRequest useCaseRequest = - BrowseTrafficsUseCaseRequest.builder().trafficId(trafficId).build(); + BrowseTrafficsUseCaseIn useCaseRequest = + BrowseTrafficsUseCaseIn.builder().trafficId(trafficId).build(); String authorization = request.getHeader(HttpHeaders.AUTHORIZATION); - BrowseTrafficsUseCaseResponse response = null; + BrowseTrafficsUseCaseOut response = null; if (Objects.nonNull(authorization)) { String token = AccessTokenResolver.resolve(authorization); UserDetails userDetails = tokenUserDetailsService.loadUserByUsername(token); @@ -98,7 +98,7 @@ public ApiResponse addFavoriteTraffic( @Valid @RequestBody FavoriteTrafficBody favoriteTrafficBody) { Long memberId = Long.valueOf(userDetails.getUsername()); addFavoriteTrafficUseCase.execute( - AddFavoriteTrafficUseCaseRequest.builder() + AddFavoriteTrafficUseCaseIn.builder() .memberId(memberId) .trafficId(favoriteTrafficBody.getTrafficId()) .trafficAlias(favoriteTrafficBody.getTrafficAlias()) @@ -107,7 +107,7 @@ public ApiResponse addFavoriteTraffic( } @GetMapping("/favorite") - public ApiResponse> + public ApiResponse> browseFavoriteTraffics(HttpServletRequest request) { Long memberId = null; String authorization = request.getHeader(HttpHeaders.AUTHORIZATION); @@ -119,9 +119,9 @@ public ApiResponse addFavoriteTraffic( throw new IllegalArgumentException("Authorization header is required."); } - BrowseFavoriteTrafficsUseCaseRequest useCaseRequest = - BrowseFavoriteTrafficsUseCaseRequest.builder().memberId(memberId).build(); - BrowseFavoriteTrafficsUseCaseResponse response = + BrowseFavoriteTrafficsUseCaseIn useCaseRequest = + BrowseFavoriteTrafficsUseCaseIn.builder().memberId(memberId).build(); + BrowseFavoriteTrafficsUseCaseOut response = browseFavoriteTrafficsUseCase.execute(useCaseRequest); return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.SUCCESS); } @@ -133,7 +133,7 @@ public ApiResponse updateFavoriteTraffic( @Valid @RequestBody PatchFavoriteTrafficNameBody patchFavoriteTrafficNameBody) { Long memberId = Long.valueOf(userDetails.getUsername()); updateFavoriteTrafficUseCase.execute( - UpdateFavoriteTrafficUseCaseRequest.builder() + UpdateFavoriteTrafficUseCaseIn.builder() .memberId(memberId) .favoriteTrafficId(trafficId) .trafficAlias(patchFavoriteTrafficNameBody.getTrafficAlias()) @@ -146,7 +146,7 @@ public ApiResponse deleteFavoriteTraffic( @AuthenticationPrincipal TokenUserDetails userDetails, @Min(1) @PathVariable Long trafficId) { Long memberId = Long.valueOf(userDetails.getUsername()); deleteFavoriteTrafficUseCase.execute( - DeleteFavoriteTrafficUseCaseRequest.builder() + DeleteFavoriteTrafficUseCaseIn.builder() .memberId(memberId) .favoriteTrafficId(trafficId) .build()); diff --git a/api/src/main/java/com/walking/api/web/dto/support/TrafficDetailConverter.java b/api/src/main/java/com/walking/api/web/dto/support/TrafficDetailConverter.java index b072307e..0d0adf10 100644 --- a/api/src/main/java/com/walking/api/web/dto/support/TrafficDetailConverter.java +++ b/api/src/main/java/com/walking/api/web/dto/support/TrafficDetailConverter.java @@ -7,7 +7,7 @@ import com.walking.api.domain.traffic.dto.detail.PointDetail; import com.walking.api.domain.traffic.dto.detail.TrafficDetail; import com.walking.api.domain.traffic.dto.detail.TrafficDetailInfo; -import com.walking.api.domain.traffic.service.model.PredictedData; +import com.walking.api.domain.traffic.service.model.PredictedTraffic; import com.walking.data.entity.traffic.TrafficEntity; import java.util.List; import java.util.Optional; @@ -20,13 +20,13 @@ public class TrafficDetailConverter { /** * PredictedData를 기반으로 TrafficDetail를 생성합니다. * - * @param predictedData 사이클 정보 와 현재 색상 및 잔여시간을 예측한 데이터 + * @param predictedTraffic 사이클 정보 와 현재 색상 및 잔여시간을 예측한 데이터 * @return 예측 값을 바탕으로 만든 TrafficDetail */ public TrafficDetail execute( - PredictedData predictedData, Optional favoriteTrafficDetail) { + PredictedTraffic predictedTraffic, Optional favoriteTrafficDetail) { - TrafficEntity trafficEntity = predictedData.getTraffic(); + TrafficEntity trafficEntity = predictedTraffic.getTraffic(); boolean isFavorite = false; String viewName = trafficEntity.getName(); @@ -38,12 +38,12 @@ public TrafficDetail execute( return TrafficDetail.builder() .id(trafficEntity.getId()) - .color(predictedData.getCurrentColorDescription()) - .timeLeft(predictedData.getCurrentTimeLeft().orElse(null)) + .color(predictedTraffic.getCurrentColorDescription()) + .timeLeft(predictedTraffic.getCurrentTimeLeft().orElse(null)) .point( PointDetail.builder().lng(trafficEntity.getLng()).lat(trafficEntity.getLat()).build()) - .redCycle(predictedData.getRedCycle().orElse(null)) - .greenCycle(predictedData.getGreenCycle().orElse(null)) + .redCycle(predictedTraffic.getRedCycle().orElse(null)) + .greenCycle(predictedTraffic.getGreenCycle().orElse(null)) .detail(convertToTrafficDetailInfo(trafficEntity)) .isFavorite(isFavorite) .viewName(viewName) @@ -56,7 +56,7 @@ public TrafficDetail execute( * @param predictedData 사이클 정보 와 현재 색상 및 잔여시간을 예측한 데이터 리스트 * @return 예측 값을 바탕으로 만든 TrafficDetail의 List */ - public List execute(List predictedData) { + public List execute(List predictedData) { return predictedData.stream() .map( diff --git a/api/src/test/java/com/walking/api/service/TrafficPredictServiceTest.java b/api/src/test/java/com/walking/api/service/TrafficPredictServiceTest.java index 921267cb..dcfac4a0 100644 --- a/api/src/test/java/com/walking/api/service/TrafficPredictServiceTest.java +++ b/api/src/test/java/com/walking/api/service/TrafficPredictServiceTest.java @@ -2,8 +2,8 @@ import com.walking.api.ApiApp; import com.walking.api.domain.traffic.service.TrafficPredictService; -import com.walking.api.domain.traffic.service.dto.TrafficPredictServiceRequest; -import com.walking.api.domain.traffic.service.model.PredictedData; +import com.walking.api.domain.traffic.service.dto.TPQuery; +import com.walking.api.domain.traffic.service.model.PredictedTraffic; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -26,9 +26,9 @@ class TrafficPredictServiceTest { @ParameterizedTest @MethodSource("getTrafficIds") void example(List trafficIds) { - Map predictedDataMap = + Map predictedDataMap = integrationPredictService - .execute(TrafficPredictServiceRequest.builder().trafficIds(trafficIds).build()) + .execute(TPQuery.builder().trafficIds(trafficIds).build()) .getPredictedData(); for (Long trafficId : predictedDataMap.keySet()) { diff --git a/api/src/test/java/com/walking/api/web/controller/member/MemberControllerTest.java b/api/src/test/java/com/walking/api/web/controller/member/MemberControllerTest.java index b2770762..11947b24 100644 --- a/api/src/test/java/com/walking/api/web/controller/member/MemberControllerTest.java +++ b/api/src/test/java/com/walking/api/web/controller/member/MemberControllerTest.java @@ -2,7 +2,6 @@ import static com.epages.restdocs.apispec.ResourceDocumentation.resource; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.Mockito.when; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; @@ -23,11 +22,11 @@ import com.walking.api.web.dto.request.member.PatchProfileBody; import com.walking.api.web.dto.request.member.PostMemberBody; import com.walking.api.web.dto.request.member.RefreshMemberAuthTokenBody; -import com.walking.member.api.dto.DeleteMemberUseCaseResponse; -import com.walking.member.api.dto.GetMemberDetailUseCaseResponse; -import com.walking.member.api.dto.GetMemberTokenDetailUseCaseResponse; -import com.walking.member.api.dto.PatchProfileImageUseCaseResponse; -import com.walking.member.api.dto.PostMemberUseCaseResponse; +import com.walking.member.api.dto.DeleteMemberUseCaseOut; +import com.walking.member.api.dto.GetMemberDetailUseCaseOut; +import com.walking.member.api.dto.GetMemberTokenDetailUseCaseOut; +import com.walking.member.api.dto.PatchProfileImageUseCaseOut; +import com.walking.member.api.dto.PostMemberUseCaseOut; import com.walking.member.api.usecase.DeleteMemberUseCase; import com.walking.member.api.usecase.GetMemberDetailUseCase; import com.walking.member.api.usecase.GetMemberTokenDetailUseCase; @@ -79,7 +78,7 @@ class MemberControllerTest { @WithUserDetails(userDetailsServiceBeanName = "testTokenUserDetailsService") void postMember() throws Exception { when(postMemberUseCase.execute(any())) - .thenReturn(new PostMemberUseCaseResponse(1L, "nickname", "profile")); + .thenReturn(new PostMemberUseCaseOut(1L, "nickname", "profile")); when(tokenGenerator.generateAuthToken(any(), any())) .thenReturn(new AuthToken("accessToken", "refreshToken")); @@ -133,8 +132,8 @@ void postMember() throws Exception { @DisplayName("DELETE /api/v1/members 회원 탈퇴를 한다.") @WithUserDetails(userDetailsServiceBeanName = "testTokenUserDetailsService") void deleteMember() throws Exception { - when(deleteMemberUseCase.execute(anyLong())) - .thenReturn(new DeleteMemberUseCaseResponse(1L, LocalDateTime.now())); + when(deleteMemberUseCase.execute(any())) + .thenReturn(new DeleteMemberUseCaseOut(1L, LocalDateTime.now())); mockMvc .perform( @@ -172,8 +171,8 @@ void deleteMember() throws Exception { @DisplayName("GET /api/v1/members 회원 정보를 조회한다.") @WithUserDetails(userDetailsServiceBeanName = "testTokenUserDetailsService") void getMember() throws Exception { - when(getMemberDetailUseCase.execute(anyLong())) - .thenReturn(new GetMemberDetailUseCaseResponse(1L, "nickname", "profile", "KAKAO", "정회원")); + when(getMemberDetailUseCase.execute(any())) + .thenReturn(new GetMemberDetailUseCaseOut(1L, "nickname", "profile", "KAKAO", "정회원")); mockMvc .perform( @@ -216,8 +215,8 @@ void getMember() throws Exception { void getMemberToken() throws Exception { when(tokenResolver.resolveId(any())).thenReturn(Optional.of(1L)); - when(getMemberTokenDetailUseCase.execute(anyLong())) - .thenReturn(new GetMemberTokenDetailUseCaseResponse(1L)); + when(getMemberTokenDetailUseCase.execute(any())) + .thenReturn(new GetMemberTokenDetailUseCaseOut(1L)); when(tokenGenerator.generateAuthToken(any(), any())) .thenReturn(new AuthToken("accessToken", "refreshToken")); @@ -259,8 +258,8 @@ void getMemberToken() throws Exception { @DisplayName("PATCH /api/v1/members/profile 프로필 이미지를 수정한다.") @WithUserDetails(userDetailsServiceBeanName = "testTokenUserDetailsService") void patchProfile() throws Exception { - when(patchProfileImageUseCase.execute(anyLong(), any())) - .thenReturn(new PatchProfileImageUseCaseResponse(1L, "nickname", "profile")); + when(patchProfileImageUseCase.execute(any())) + .thenReturn(new PatchProfileImageUseCaseOut(1L, "nickname", "profile")); File file = makeFile("src/test/resources/images", "test", "png"); PatchProfileBody patchProfileBody = diff --git a/api/src/test/java/com/walking/api/web/controller/traffic/TrafficControllerTest.java b/api/src/test/java/com/walking/api/web/controller/traffic/TrafficControllerTest.java index b49324e5..738f7fd2 100644 --- a/api/src/test/java/com/walking/api/web/controller/traffic/TrafficControllerTest.java +++ b/api/src/test/java/com/walking/api/web/controller/traffic/TrafficControllerTest.java @@ -17,7 +17,7 @@ import com.epages.restdocs.apispec.SimpleType; import com.fasterxml.jackson.databind.ObjectMapper; import com.walking.api.ApiApp; -import com.walking.api.domain.traffic.dto.BrowseFavoriteTrafficsUseCaseResponse; +import com.walking.api.domain.traffic.dto.BrowseFavoriteTrafficsUseCaseOut; import com.walking.api.domain.traffic.dto.detail.FavoriteTrafficDetail; import com.walking.api.domain.traffic.dto.detail.PointDetail; import com.walking.api.domain.traffic.dto.detail.TrafficDetailInfo; @@ -366,7 +366,7 @@ void browseFavoriteTraffics() throws Exception { when(browseFavoriteTrafficsUseCase.execute(any())) .thenReturn( - BrowseFavoriteTrafficsUseCaseResponse.builder() + BrowseFavoriteTrafficsUseCaseOut.builder() .traffics( List.of( FavoriteTrafficDetail.builder() diff --git a/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberTokenDetailUseCaseResponse.kt b/member-api/src/main/kotlin/com/walking/member/api/dto/DeleteMemberUseCaseIn.kt similarity index 52% rename from member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberTokenDetailUseCaseResponse.kt rename to member-api/src/main/kotlin/com/walking/member/api/dto/DeleteMemberUseCaseIn.kt index f9382b11..35c3b025 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberTokenDetailUseCaseResponse.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/dto/DeleteMemberUseCaseIn.kt @@ -1,5 +1,5 @@ package com.walking.member.api.dto -data class GetMemberTokenDetailUseCaseResponse( +data class DeleteMemberUseCaseIn( val id: Long ) \ No newline at end of file diff --git a/member-api/src/main/kotlin/com/walking/member/api/dto/DeleteMemberUseCaseResponse.kt b/member-api/src/main/kotlin/com/walking/member/api/dto/DeleteMemberUseCaseOut.kt similarity index 75% rename from member-api/src/main/kotlin/com/walking/member/api/dto/DeleteMemberUseCaseResponse.kt rename to member-api/src/main/kotlin/com/walking/member/api/dto/DeleteMemberUseCaseOut.kt index 58a34f07..000cb804 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/dto/DeleteMemberUseCaseResponse.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/dto/DeleteMemberUseCaseOut.kt @@ -2,7 +2,7 @@ package com.walking.member.api.dto import java.time.LocalDateTime -data class DeleteMemberUseCaseResponse( +data class DeleteMemberUseCaseOut( val id: Long, val deletedAt: LocalDateTime ) \ No newline at end of file diff --git a/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberDetailUseCaseIn.kt b/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberDetailUseCaseIn.kt new file mode 100644 index 00000000..4dc2ab98 --- /dev/null +++ b/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberDetailUseCaseIn.kt @@ -0,0 +1,5 @@ +package com.walking.member.api.dto + +data class GetMemberDetailUseCaseIn( + val id: Long +) \ No newline at end of file diff --git a/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberDetailUseCaseResponse.kt b/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberDetailUseCaseOut.kt similarity index 79% rename from member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberDetailUseCaseResponse.kt rename to member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberDetailUseCaseOut.kt index a3f14f21..4d663593 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberDetailUseCaseResponse.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberDetailUseCaseOut.kt @@ -1,6 +1,6 @@ package com.walking.member.api.dto -data class GetMemberDetailUseCaseResponse( +data class GetMemberDetailUseCaseOut( val id: Long, val nickName: String, val profile: String, diff --git a/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberTokenDetailUseCaseIn.kt b/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberTokenDetailUseCaseIn.kt new file mode 100644 index 00000000..f307201a --- /dev/null +++ b/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberTokenDetailUseCaseIn.kt @@ -0,0 +1,5 @@ +package com.walking.member.api.dto + +data class GetMemberTokenDetailUseCaseIn( + val id: Long +) \ No newline at end of file diff --git a/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberTokenDetailUseCaseOut.kt b/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberTokenDetailUseCaseOut.kt new file mode 100644 index 00000000..b3b3418f --- /dev/null +++ b/member-api/src/main/kotlin/com/walking/member/api/dto/GetMemberTokenDetailUseCaseOut.kt @@ -0,0 +1,5 @@ +package com.walking.member.api.dto + +data class GetMemberTokenDetailUseCaseOut( + val id: Long +) \ No newline at end of file diff --git a/member-api/src/main/kotlin/com/walking/member/api/dto/PatchProfileImageUseCaseIn.kt b/member-api/src/main/kotlin/com/walking/member/api/dto/PatchProfileImageUseCaseIn.kt new file mode 100644 index 00000000..50fbeab1 --- /dev/null +++ b/member-api/src/main/kotlin/com/walking/member/api/dto/PatchProfileImageUseCaseIn.kt @@ -0,0 +1,8 @@ +package com.walking.member.api.dto + +import java.io.File + +data class PatchProfileImageUseCaseIn( + val id: Long, + val image: File +) \ No newline at end of file diff --git a/member-api/src/main/kotlin/com/walking/member/api/dto/PatchProfileImageUseCaseResponse.kt b/member-api/src/main/kotlin/com/walking/member/api/dto/PatchProfileImageUseCaseOut.kt similarity index 70% rename from member-api/src/main/kotlin/com/walking/member/api/dto/PatchProfileImageUseCaseResponse.kt rename to member-api/src/main/kotlin/com/walking/member/api/dto/PatchProfileImageUseCaseOut.kt index c5285ae9..5cd97368 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/dto/PatchProfileImageUseCaseResponse.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/dto/PatchProfileImageUseCaseOut.kt @@ -1,6 +1,6 @@ package com.walking.member.api.dto -data class PatchProfileImageUseCaseResponse( +data class PatchProfileImageUseCaseOut( val id: Long, val nickName: String, val profile: String diff --git a/member-api/src/main/kotlin/com/walking/member/api/dto/PostMemberUseCaseIn.kt b/member-api/src/main/kotlin/com/walking/member/api/dto/PostMemberUseCaseIn.kt new file mode 100644 index 00000000..bf960b3d --- /dev/null +++ b/member-api/src/main/kotlin/com/walking/member/api/dto/PostMemberUseCaseIn.kt @@ -0,0 +1,5 @@ +package com.walking.member.api.dto + +data class PostMemberUseCaseIn( + val code: String +) \ No newline at end of file diff --git a/member-api/src/main/kotlin/com/walking/member/api/dto/PostMemberUseCaseResponse.kt b/member-api/src/main/kotlin/com/walking/member/api/dto/PostMemberUseCaseOut.kt similarity index 73% rename from member-api/src/main/kotlin/com/walking/member/api/dto/PostMemberUseCaseResponse.kt rename to member-api/src/main/kotlin/com/walking/member/api/dto/PostMemberUseCaseOut.kt index ede5b172..35c76a14 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/dto/PostMemberUseCaseResponse.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/dto/PostMemberUseCaseOut.kt @@ -1,6 +1,6 @@ package com.walking.member.api.dto -data class PostMemberUseCaseResponse( +data class PostMemberUseCaseOut( val id: Long, val nickname: String, val profile: String diff --git a/member-api/src/main/kotlin/com/walking/member/api/service/kakao/PostKaKaoMemberService.kt b/member-api/src/main/kotlin/com/walking/member/api/service/kakao/PostKaKaoMemberService.kt index 697c5347..839a31a1 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/service/kakao/PostKaKaoMemberService.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/service/kakao/PostKaKaoMemberService.kt @@ -2,7 +2,8 @@ package com.walking.member.api.service.kakao import com.walking.member.api.client.support.KaKoIdTokenParser import com.walking.member.api.client.token.KaKaoIdTokenClient -import com.walking.member.api.service.kakao.dto.SocialMemberServiceDto +import com.walking.member.api.service.kakao.dto.KMSQuery +import com.walking.member.api.service.kakao.dto.SocialMemberVO import org.springframework.stereotype.Service @Service @@ -11,15 +12,15 @@ class PostKaKaoMemberService(private val kaKaoIdTokenClient: KaKaoIdTokenClient, companion object { private const val SUBJECT = "KAKAO" } - fun execute(code: String): SocialMemberServiceDto { - val token = kaKaoIdTokenClient.execute(code) + fun execute(query: KMSQuery): SocialMemberVO { + val token = kaKaoIdTokenClient.execute(query.code) val idTokenProperties = kaKoIdTokenParser.parse(token.getToken()) val nickname = idTokenProperties.nickname val certificationId = idTokenProperties.sub val profile = idTokenProperties.picture - return SocialMemberServiceDto( + return SocialMemberVO( nickname, profile, certificationId, diff --git a/member-api/src/main/kotlin/com/walking/member/api/service/kakao/dto/KMSQuery.kt b/member-api/src/main/kotlin/com/walking/member/api/service/kakao/dto/KMSQuery.kt new file mode 100644 index 00000000..1a6f5947 --- /dev/null +++ b/member-api/src/main/kotlin/com/walking/member/api/service/kakao/dto/KMSQuery.kt @@ -0,0 +1,8 @@ +package com.walking.member.api.service.kakao.dto + +/** + * 카카오 로그인 요청시 사용되는 쿼리 + */ +data class KMSQuery( + val code: String +) \ No newline at end of file diff --git a/member-api/src/main/kotlin/com/walking/member/api/service/kakao/dto/SocialMemberServiceDto.kt b/member-api/src/main/kotlin/com/walking/member/api/service/kakao/dto/SocialMemberVO.kt similarity index 83% rename from member-api/src/main/kotlin/com/walking/member/api/service/kakao/dto/SocialMemberServiceDto.kt rename to member-api/src/main/kotlin/com/walking/member/api/service/kakao/dto/SocialMemberVO.kt index 6ec639be..eff47974 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/service/kakao/dto/SocialMemberServiceDto.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/service/kakao/dto/SocialMemberVO.kt @@ -1,6 +1,6 @@ package com.walking.member.api.service.kakao.dto -data class SocialMemberServiceDto( +data class SocialMemberVO( val nickName: String, var profile: String, val certificationId: String, diff --git a/member-api/src/main/kotlin/com/walking/member/api/usecase/DeleteMemberUseCase.kt b/member-api/src/main/kotlin/com/walking/member/api/usecase/DeleteMemberUseCase.kt index 5ab4639a..f0136c8e 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/usecase/DeleteMemberUseCase.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/usecase/DeleteMemberUseCase.kt @@ -4,7 +4,8 @@ import com.walking.data.entity.member.MemberEntity import com.walking.image.service.RemoveImageService import com.walking.member.api.client.unlink.SocialUnlinkClientManager import com.walking.member.api.dao.MemberDao -import com.walking.member.api.dto.DeleteMemberUseCaseResponse +import com.walking.member.api.dto.DeleteMemberUseCaseIn +import com.walking.member.api.dto.DeleteMemberUseCaseOut import org.springframework.cache.annotation.CacheEvict import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @@ -16,9 +17,9 @@ class DeleteMemberUseCase( private val unlinkClientManager: SocialUnlinkClientManager ) { @Transactional - @CacheEvict(key = "#id", cacheManager = "memberApiCacheManager", cacheNames = ["member-profile"]) - fun execute(id: Long): DeleteMemberUseCaseResponse { - val member = memberRepository.findById(id) ?: throw IllegalArgumentException("Member not found") + @CacheEvict(key = "#useCaseIn.id", cacheManager = "memberApiCacheManager", cacheNames = ["member-profile"]) + fun execute(useCaseIn: DeleteMemberUseCaseIn): DeleteMemberUseCaseOut { + val member = memberRepository.findById(useCaseIn.id) ?: throw IllegalArgumentException("Member not found") val deletedMember = withdrawMember(member) removeImageService.execute(deletedMember.profile) unlinkClientManager.execute( @@ -26,7 +27,7 @@ class DeleteMemberUseCase( deletedMember.certificationId ) - return DeleteMemberUseCaseResponse(deletedMember.id, deletedMember.updatedAt) + return DeleteMemberUseCaseOut(deletedMember.id, deletedMember.updatedAt) } private fun withdrawMember(member: MemberEntity): MemberEntity { diff --git a/member-api/src/main/kotlin/com/walking/member/api/usecase/GetMemberDetailUseCase.kt b/member-api/src/main/kotlin/com/walking/member/api/usecase/GetMemberDetailUseCase.kt index 6349cb62..a56edcf6 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/usecase/GetMemberDetailUseCase.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/usecase/GetMemberDetailUseCase.kt @@ -2,8 +2,9 @@ package com.walking.member.api.usecase import com.walking.image.service.GetPreSignedImageUrlService import com.walking.member.api.dao.MemberDao +import com.walking.member.api.dto.GetMemberDetailUseCaseIn -import com.walking.member.api.dto.GetMemberDetailUseCaseResponse +import com.walking.member.api.dto.GetMemberDetailUseCaseOut import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.cache.annotation.Cacheable @@ -18,16 +19,16 @@ class GetMemberDetailUseCase( val log: Logger = LoggerFactory.getLogger(GetMemberDetailUseCase::class.java) @Transactional - @Cacheable(key = "#id", cacheManager = "memberApiCacheManager", cacheNames = ["member-profile"]) - fun execute(id: Long): GetMemberDetailUseCaseResponse { - val member = memberRepository.findById(id) ?: throw IllegalArgumentException("Member not found") + @Cacheable(key = "#useCaseIn.id", cacheManager = "memberApiCacheManager", cacheNames = ["member-profile"]) + fun execute(useCaseIn: GetMemberDetailUseCaseIn): GetMemberDetailUseCaseOut { + val member = memberRepository.findById(useCaseIn.id) ?: throw IllegalArgumentException("Member not found") val id = member.id val nickName = member.nickName val certificationSubject = member.certificationSubject.name val status = member.status.name var profile = getProfile(member.profile) - return GetMemberDetailUseCaseResponse( + return GetMemberDetailUseCaseOut( id, nickName, profile, diff --git a/member-api/src/main/kotlin/com/walking/member/api/usecase/GetMemberTokenDetailUseCase.kt b/member-api/src/main/kotlin/com/walking/member/api/usecase/GetMemberTokenDetailUseCase.kt index 6092bf91..6e2456b6 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/usecase/GetMemberTokenDetailUseCase.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/usecase/GetMemberTokenDetailUseCase.kt @@ -1,15 +1,18 @@ package com.walking.member.api.usecase import com.walking.member.api.dao.MemberDao -import com.walking.member.api.dto.GetMemberTokenDetailUseCaseResponse +import com.walking.member.api.dto.GetMemberTokenDetailUseCaseIn +import com.walking.member.api.dto.GetMemberTokenDetailUseCaseOut import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @Service class GetMemberTokenDetailUseCase(private val memberRepository: MemberDao) { @Transactional - fun execute(id: Long): GetMemberTokenDetailUseCaseResponse { - val member = memberRepository.findById(id) ?: throw IllegalArgumentException("Member not found") - return GetMemberTokenDetailUseCaseResponse(member.id) + fun execute(useCaseIn: GetMemberTokenDetailUseCaseIn): GetMemberTokenDetailUseCaseOut { + val member = memberRepository.findById( + useCaseIn.id + ) ?: throw IllegalArgumentException("Member not found") + return GetMemberTokenDetailUseCaseOut(member.id) } } \ No newline at end of file diff --git a/member-api/src/main/kotlin/com/walking/member/api/usecase/PatchProfileImageUseCase.kt b/member-api/src/main/kotlin/com/walking/member/api/usecase/PatchProfileImageUseCase.kt index 8699c089..73fd0f35 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/usecase/PatchProfileImageUseCase.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/usecase/PatchProfileImageUseCase.kt @@ -2,11 +2,11 @@ package com.walking.member.api.usecase import com.walking.image.service.UploadImageService import com.walking.member.api.dao.MemberDao +import com.walking.member.api.dto.PatchProfileImageUseCaseIn import com.walking.member.api.service.delegator.CacheAbleMemberProfileUpdateDelegator -import com.walking.member.api.dto.PatchProfileImageUseCaseResponse +import com.walking.member.api.dto.PatchProfileImageUseCaseOut import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional -import java.io.File import java.time.LocalDate import kotlin.random.Random @@ -17,14 +17,14 @@ class PatchProfileImageUseCase( private val memberProfileUpdateDelegator: CacheAbleMemberProfileUpdateDelegator ) { @Transactional - fun execute(id: Long, image: File): PatchProfileImageUseCaseResponse { - val member = memberDao.findById(id) ?: throw IllegalArgumentException("Member not found") + fun execute(useCaseIn: PatchProfileImageUseCaseIn): PatchProfileImageUseCaseOut { + val member = memberDao.findById(useCaseIn.id) ?: throw IllegalArgumentException("Member not found") val imageName = generateImageName() - uploadImageService.execute(imageName, image).let { + uploadImageService.execute(imageName, useCaseIn.image).let { memberProfileUpdateDelegator.execute(member, imageName).let { member -> memberDao.save(member) - return PatchProfileImageUseCaseResponse(member.id, member.nickName, imageName) + return PatchProfileImageUseCaseOut(member.id, member.nickName, imageName) } } } diff --git a/member-api/src/main/kotlin/com/walking/member/api/usecase/PostMemberUseCase.kt b/member-api/src/main/kotlin/com/walking/member/api/usecase/PostMemberUseCase.kt index 130bbfc3..89f184a3 100644 --- a/member-api/src/main/kotlin/com/walking/member/api/usecase/PostMemberUseCase.kt +++ b/member-api/src/main/kotlin/com/walking/member/api/usecase/PostMemberUseCase.kt @@ -2,9 +2,11 @@ package com.walking.member.api.usecase import com.walking.data.entity.member.MemberEntity import com.walking.member.api.dao.MemberDao -import com.walking.member.api.service.kakao.dto.SocialMemberServiceDto -import com.walking.member.api.dto.PostMemberUseCaseResponse +import com.walking.member.api.dto.PostMemberUseCaseIn +import com.walking.member.api.service.kakao.dto.SocialMemberVO +import com.walking.member.api.dto.PostMemberUseCaseOut import com.walking.member.api.service.kakao.PostKaKaoMemberService +import com.walking.member.api.service.kakao.dto.KMSQuery import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @@ -18,21 +20,21 @@ class PostMemberUseCase( ) { @Transactional - fun execute(code: String): PostMemberUseCaseResponse { - val socialMember = createKaKaoMemberService.execute(code) + fun execute(useCaseIn: PostMemberUseCaseIn): PostMemberUseCaseOut { + val socialMember = createKaKaoMemberService.execute(KMSQuery(useCaseIn.code)) memberRepository.findByCertificationId(socialMember.certificationId) ?.let { member -> - return PostMemberUseCaseResponse(member.id, member.nickName, member.profile) + return PostMemberUseCaseOut(member.id, member.nickName, member.profile) } val newMember = createMemberEntity(socialMember) memberRepository.save(newMember).let { member -> - return PostMemberUseCaseResponse(member.id, member.nickName, member.profile) + return PostMemberUseCaseOut(member.id, member.nickName, member.profile) } } - private fun createMemberEntity(socialMember: SocialMemberServiceDto): MemberEntity { + private fun createMemberEntity(socialMember: SocialMemberVO): MemberEntity { Random().nextInt(defaultProfiles.size).let { index -> socialMember.profile = defaultProfiles[index] }