parent
54277d39af
commit
54e3a8d08c
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.mashibing.internalcommon.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预估价格 请求响应类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ForecastPriceResponse {
|
||||||
|
|
||||||
|
private double price;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue