- server 模块这里应用配置也没过多的“添加剂”。
Common
Pom.xml
<?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>product</artifactId> <groupId>com.imooc</groupId> <version>0.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>product-common</artifactId> <dependencies> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> </dependencies> </project>
package com.imooc.product.common; import lombok.Data; /** * 减库存入参 */ @Data public class DecreaseStockInput { private String productId; private Integer productQuantity; public DecreaseStockInput() { } public DecreaseStockInput(String productId, Integer productQuantity) { this.productId = productId; this.productQuantity = productQuantity; } } package com.imooc.product.common; import lombok.Data; import java.math.BigDecimal; @Data public class ProductInfoOutput { private String productId; /** 名字. */ private String productName; /** 单价. */ private BigDecimal productPrice; /** 库存. */ private Integer productStock; /** 描述. */ private String productDescription; /** 小图. */ private String productIcon; /** 状态, 0正常1下架. */ private Integer productStatus; /** 类目编号. */ private Integer categoryType; }
Client
Pom.xml
<?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>product</artifactId> <groupId>com.imooc</groupId> <version>0.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>product-client</artifactId> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency> <dependency> <groupId>com.imooc</groupId> <artifactId>product-common</artifactId> </dependency> </dependencies> </project>
package com.imooc.product.client; import com.imooc.product.common.DecreaseStockInput; import com.imooc.product.common.ProductInfoOutput; import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @FeignClient(name = "product") public interface ProductClient { @PostMapping("/product/listForOrder") List<ProductInfoOutput> listForOrder(@RequestBody List<String> productIdList); @PostMapping("/product/decreaseStock") void decreaseStock(@RequestBody List<DecreaseStockInput> decreaseStockInputList); }
Order 微服务项目