From 54e3a8d08ca1f9d0473c0b8e80cd47fd263cfb78 Mon Sep 17 00:00:00 2001 From: yh <1844516659@qq.com> Date: Mon, 18 Jul 2022 08:29:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=9E=E6=BB=B4=E5=87=BA=E8=A1=8C=E7=BD=91?= =?UTF-8?q?=E7=BA=A6=E8=BD=A62022-api-passenger=20=E9=A2=84=E4=BC=B0?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E6=8E=A5=E5=8F=A3=E8=AE=BE=E8=AE=A1=E9=AA=A8?= =?UTF-8?q?=E6=9E=B6=E7=BC=96=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ForecastPriceController.java | 28 ++++++++++++++ .../service/ForecastPriceService.java | 38 +++++++++++++++++++ .../request/ForecastPriceDTO.java | 13 +++++++ .../response/ForecastPriceResponse.java | 13 +++++++ 4 files changed, 92 insertions(+) create mode 100644 api-passenger/src/main/java/com/mashibing/apipassenger/controller/ForecastPriceController.java create mode 100644 api-passenger/src/main/java/com/mashibing/apipassenger/service/ForecastPriceService.java create mode 100644 internal-common/src/main/java/com/mashibing/internalcommon/request/ForecastPriceDTO.java create mode 100644 internal-common/src/main/java/com/mashibing/internalcommon/response/ForecastPriceResponse.java diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/controller/ForecastPriceController.java b/api-passenger/src/main/java/com/mashibing/apipassenger/controller/ForecastPriceController.java new file mode 100644 index 0000000..d10cf05 --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/controller/ForecastPriceController.java @@ -0,0 +1,28 @@ +package com.mashibing.apipassenger.controller; + +import com.mashibing.apipassenger.service.ForecastPriceService; +import com.mashibing.internalcommon.dto.ResponseResult; +import com.mashibing.internalcommon.request.ForecastPriceDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ForecastPriceController { + + @Autowired + private ForecastPriceService priceService; + + @PostMapping("/forecast-price") + public ResponseResult forecastPrice(@RequestBody ForecastPriceDTO forecastPriceDTO){ + + String depLongitude = forecastPriceDTO. getDepLongitude(); + String depLatitude = forecastPriceDTO.getDepLatitude(); + String destLongitude = forecastPriceDTO.getDestLongitude(); + String destLatitude = forecastPriceDTO.getDestLatitude(); + + return priceService.forecastPrice(depLongitude,destLatitude,destLongitude,destLongitude); + } + +} diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/service/ForecastPriceService.java b/api-passenger/src/main/java/com/mashibing/apipassenger/service/ForecastPriceService.java new file mode 100644 index 0000000..79cfefa --- /dev/null +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/service/ForecastPriceService.java @@ -0,0 +1,38 @@ +package com.mashibing.apipassenger.service; + +import com.mashibing.internalcommon.dto.ResponseResult; +import com.mashibing.internalcommon.request.ForecastPriceDTO; +import com.mashibing.internalcommon.response.ForecastPriceResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + + +@Slf4j +@Service +public class ForecastPriceService { + + /** + * 根据 出发地和目地的 地经纬度 计算预估价格 + * @param depLongitude + * @param depLatitude + * @param destLongitude + * @param destLatitude + * @return + */ + public ResponseResult forecastPrice(String depLongitude, String depLatitude, String destLongitude,String destLatitude){ + + log.info("出发地经度:"+depLongitude); + log.info("出发地纬度:"+depLatitude); + log.info("目的地经度:"+destLongitude); + log.info("目的地纬度:"+destLatitude); + + // 调用 计价服务,进行价格预估 + + + ForecastPriceResponse priceResponse = new ForecastPriceResponse(); + priceResponse.setPrice(12.34); + + return ResponseResult.success(priceResponse); + } + +} diff --git a/internal-common/src/main/java/com/mashibing/internalcommon/request/ForecastPriceDTO.java b/internal-common/src/main/java/com/mashibing/internalcommon/request/ForecastPriceDTO.java new file mode 100644 index 0000000..1e29e13 --- /dev/null +++ b/internal-common/src/main/java/com/mashibing/internalcommon/request/ForecastPriceDTO.java @@ -0,0 +1,13 @@ +package com.mashibing.internalcommon.request; + +import lombok.Data; + +@Data +public class ForecastPriceDTO { + + private String depLongitude; + private String depLatitude; + private String destLongitude; + private String destLatitude; + +} diff --git a/internal-common/src/main/java/com/mashibing/internalcommon/response/ForecastPriceResponse.java b/internal-common/src/main/java/com/mashibing/internalcommon/response/ForecastPriceResponse.java new file mode 100644 index 0000000..22f108f --- /dev/null +++ b/internal-common/src/main/java/com/mashibing/internalcommon/response/ForecastPriceResponse.java @@ -0,0 +1,13 @@ +package com.mashibing.internalcommon.response; + +import lombok.Data; + +/** + * 预估价格 请求响应类 + */ +@Data +public class ForecastPriceResponse { + + private double price; + +}