diff --git a/online-taxi-public/servcie-price/src/main/java/com/taxi/Main.java b/online-taxi-public/servcie-price/src/main/java/com/taxi/Main.java deleted file mode 100644 index f3a4f31..0000000 --- a/online-taxi-public/servcie-price/src/main/java/com/taxi/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.taxi; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/ServicePriceApplication.java b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/ServicePriceApplication.java new file mode 100644 index 0000000..8207fda --- /dev/null +++ b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/ServicePriceApplication.java @@ -0,0 +1,12 @@ +package com.taxi.serviceprice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ServicePriceApplication { + + public static void main(String[] args) { + SpringApplication.run(ServicePriceApplication.class); + } +} diff --git a/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/controller/ForecastPriceController.java b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/controller/ForecastPriceController.java new file mode 100644 index 0000000..c3203cc --- /dev/null +++ b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/controller/ForecastPriceController.java @@ -0,0 +1,28 @@ +package com.taxi.serviceprice.controller; + +import com.internal.dto.ResponseResult; +import com.internal.request.ForecastPriceDTO; +import com.taxi.serviceprice.service.ForecastPriceService; +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 forecastPriceService; + + @PostMapping("/forecast-price") + public ResponseResult forecastPrice(@RequestBody ForecastPriceDTO forecastPriceDTO){ + String depLongitude = forecastPriceDTO.getDepLongitude(); + String depLatitude = forecastPriceDTO.getDestLatitude(); + + String destLongitude = forecastPriceDTO.getDestLongitude(); + String destLatitude = forecastPriceDTO.getDestLatitude(); + + return forecastPriceService.forecastPrice(depLongitude,depLatitude, + destLongitude,destLatitude); + } +} diff --git a/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/service/ForecastPriceService.java b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/service/ForecastPriceService.java new file mode 100644 index 0000000..df66ba3 --- /dev/null +++ b/online-taxi-public/servcie-price/src/main/java/com/taxi/serviceprice/service/ForecastPriceService.java @@ -0,0 +1,35 @@ +package com.taxi.serviceprice.service; + +import com.internal.dto.ResponseResult; +import com.internal.response.ForecastPriceResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +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); + + log.info("调用地图服务,查询地图和时长"); + log.info("读取计价规则"); + log.info("根据距离、时长,计价规则;计算价格"); + + ForecastPriceResponse forecastPriceResponse = new ForecastPriceResponse(); + forecastPriceResponse.setPrice(12.121); + return ResponseResult.success(forecastPriceResponse); + } +} diff --git a/online-taxi-public/servcie-price/src/main/resources/application.yaml b/online-taxi-public/servcie-price/src/main/resources/application.yaml new file mode 100644 index 0000000..f0c46ab --- /dev/null +++ b/online-taxi-public/servcie-price/src/main/resources/application.yaml @@ -0,0 +1,2 @@ +server: + port: 8084 \ No newline at end of file diff --git a/online-taxi-public/servcie-price/target/classes/application.yaml b/online-taxi-public/servcie-price/target/classes/application.yaml new file mode 100644 index 0000000..f0c46ab --- /dev/null +++ b/online-taxi-public/servcie-price/target/classes/application.yaml @@ -0,0 +1,2 @@ +server: + port: 8084 \ No newline at end of file