add:实现service-price功能

master
msb_89821 2 years ago
parent c6cb02199a
commit 3eafe9f8e7

@ -0,0 +1,38 @@
package mashibing.online.text.controller;
import com.alibaba.fastjson.JSON;
import com.mashibing.dto.AddressLatiLong;
import com.mashibing.dto.PriceResult;
import com.mashibing.dto.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
* Copyright© 2020.10.20 by .All rights reserved.
* 1.
* 2.
* 3.使.
* <b>Description:</b><br>
*
* @author nod
* <b>ProjectName:</b> onelinetextplublic
* <br><b>PackageName:</b> mashibing.online.text.controller
* <br><b>ClassName:</b>
* <br><b>Date:</b> 2022/10/22 11:17
*/
@Slf4j
@RestController
public class ForecastPriceController {
@PostMapping("/getForecastPrice")
public ResponseResult getForecastPrice(@RequestBody AddressLatiLong addressLatiLong){
log.info("api-passinger 服务 请求参数={}", JSON.toJSONString(addressLatiLong));
PriceResult priceResult =new PriceResult("34.12");
return ResponseResult.success(priceResult);
}
}

@ -0,0 +1,29 @@
package mashibing.online.text.feign;
import com.mashibing.dto.AddressLatiLong;
import com.mashibing.dto.ResponseResult;
import mashibing.online.text.feign.fallback.ForecastPriceServiceImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
/**
* Copyright© 2020.10.20 by .All rights reserved.
* 1.
* 2.
* 3.使.
* <b>Description:</b><br>
*
* @author nod
* <b>ProjectName:</b> onelinetextplublic
* <br><b>PackageName:</b> mashibing.online.text.feign.fallback
* <br><b>ClassName:</b>
* <br><b>Date:</b> 2022/10/22 14:02
*/
@FeignClient(name = "service-price",fallback = ForecastPriceServiceImpl.class)
public interface ForecastPriceService {
@RequestMapping(value = "/getForecastPrice", method = RequestMethod.POST)
public ResponseResult getForecastPrice(@RequestBody AddressLatiLong addressLatiLong) ;
}

@ -0,0 +1,29 @@
package mashibing.online.text.feign.fallback;
import com.mashibing.dto.AddressLatiLong;
import com.mashibing.dto.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import mashibing.online.text.feign.ForecastPriceService;
/**
* Copyright© 2020.10.20 by .All rights reserved.
* 1.
* 2.
* 3.使.
* <b>Description:</b><br>
*
* @author nod
* <b>ProjectName:</b> onelinetextplublic
* <br><b>PackageName:</b> mashibing.online.text.feign.fallback
* <br><b>ClassName:</b>
* <br><b>Date:</b> 2022/10/22 14:13
*/
@Slf4j
public class ForecastPriceServiceImpl implements ForecastPriceService {
@Override
public ResponseResult getForecastPrice(AddressLatiLong addressLatiLong) {
log.info("调用 service - price 失败");
return ResponseResult.fail();
}
}

@ -70,6 +70,7 @@
<module>send-server</module> <module>send-server</module>
<module>untitled4</module> <module>untitled4</module>
<module>service-passenger-user</module> <module>service-passenger-user</module>
<module>service-price</module>
</modules> </modules>
<dependencyManagement> <dependencyManagement>

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>oneline-text-plublic</artifactId>
<groupId>com.mashibing</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>service-price</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.mashibing</groupId>
<artifactId>untitled4</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,25 @@
package com.mashibing.service.price;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Copyright© 2020.10.20 by .All rights reserved.
* 1.
* 2.
* 3.使.
* <b>Description:</b><br>
*
* @author nod
* <b>ProjectName:</b> onelinetextplublic
* <br><b>PackageName:</b> com.mashibing.service.price
* <br><b>ClassName:</b>
* <br><b>Date:</b> 2022/10/22 11:30
*/
@SpringBootApplication
public class ServicePriceApplication {
public static void main(String[] args) {
SpringApplication.run(ServicePriceApplication.class, args);
}
}

@ -0,0 +1,37 @@
package com.mashibing.service.price.controller;
import com.alibaba.fastjson.JSON;
import com.mashibing.dto.AddressLatiLong;
import com.mashibing.dto.PriceResult;
import com.mashibing.dto.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
* Copyright© 2020.10.20 by .All rights reserved.
* 1.
* 2.
* 3.使.
* <b>Description:</b><br>
*
* @author nod
* <b>ProjectName:</b> onelinetextplublic
* <br><b>PackageName:</b> mashibing.online.text.controller
* <br><b>ClassName:</b>
* <br><b>Date:</b> 2022/10/22 11:17
*/
@Slf4j
@RestController
public class ForecastPriceController {
@PostMapping("/getForecastPrice")
public ResponseResult getForecastPrice(@RequestBody AddressLatiLong addressLatiLong){
log.info("api-passinger 服务 请求参数={}", JSON.toJSONString(addressLatiLong));
PriceResult priceResult =new PriceResult("34.12");
return ResponseResult.success(priceResult);
}
}

@ -0,0 +1,11 @@
server:
port: 8086
spring:
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
application:
name: service-price

@ -0,0 +1,24 @@
package com.mashibing.dto;
import lombok.Data;
/**
* Copyright© 2020.10.20 by .All rights reserved.
* 1.
* 2.
* 3.使.
* <b>Description:</b><br>
*
* @author nod
* <b>ProjectName:</b> onelinetextplublic
* <br><b>PackageName:</b> com.mashibing.dto
* <br><b>ClassName:</b>
* <br><b>Date:</b> 2022/10/22 10:58
*/
@Data
public class AddressLatiLong {
private String originLong;
private String originLati;
private String destinationLong;
private String destinationLati;
}

@ -0,0 +1,26 @@
package com.mashibing.dto;
import lombok.Data;
/**
* Copyright© 2020.10.20 by .All rights reserved.
* 1.
* 2.
* 3.使.
* <b>Description:</b><br>
*
* @author nod
* <b>ProjectName:</b> onelinetextplublic
* <br><b>PackageName:</b> com.mashibing.dto
* <br><b>ClassName:</b>
* <br><b>Date:</b> 2022/10/22 11:16
*/
@Data
public class PriceResult {
private String forecastPrice;
public PriceResult(String forecastPrice) {
this.forecastPrice = forecastPrice;
}
}
Loading…
Cancel
Save