diff --git a/product/pom.xml b/product/pom.xml index 245ac07..8a3d93e 100755 --- a/product/pom.xml +++ b/product/pom.xml @@ -2,6 +2,11 @@ 4.0.0 + + product-server + product-common + product-client + org.springframework.boot spring-boot-starter-parent @@ -12,7 +17,7 @@ cn.algerfan 0.0.1-SNAPSHOT product - jar + pom product Demo project for Spring Boot @@ -22,40 +27,6 @@ Finchley.RELEASE - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-jpa - - - mysql - mysql-connector-java - - - org.projectlombok - lombok - - - - org.springframework.boot - spring-boot-starter-test - test - - - @@ -106,13 +77,4 @@ --> - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/product/product-client/pom.xml b/product/product-client/pom.xml new file mode 100644 index 0000000..0df4ffe --- /dev/null +++ b/product/product-client/pom.xml @@ -0,0 +1,30 @@ + + + + product + cn.algerfan + 0.0.1-SNAPSHOT + + 4.0.0 + + product-client + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework + spring-web + + + cn.algerfan + 0.0.1-SNAPSHOT + product-common + + + + \ No newline at end of file diff --git a/product/product-client/src/main/java/cn/algerfan/product/client/ProductClient.java b/product/product-client/src/main/java/cn/algerfan/product/client/ProductClient.java new file mode 100755 index 0000000..5b235d2 --- /dev/null +++ b/product/product-client/src/main/java/cn/algerfan/product/client/ProductClient.java @@ -0,0 +1,33 @@ +package cn.algerfan.product.client; + +import cn.algerfan.product.common.DecreaseStockOutput; +import cn.algerfan.product.common.ProductInfoOutput; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * @author algerfan + * @time 2019 21: 39 + */ +@FeignClient(name = "product") +public interface ProductClient { + + /** + * 根据id查找商品 + * @param productIdList id集合 + * @return 传输对象 + */ + @PostMapping("/product/listForOrder") + List productInfoList(@RequestBody List productIdList); + + /** + * 扣库存 + * @param decreaseStockOutputs 传输对象 + */ + @PostMapping("/product/decreaseStock") + void decreaseStock(@RequestBody List decreaseStockOutputs); + +} diff --git a/product/product-common/pom.xml b/product/product-common/pom.xml new file mode 100644 index 0000000..5415fda --- /dev/null +++ b/product/product-common/pom.xml @@ -0,0 +1,21 @@ + + + + product + cn.algerfan + 0.0.1-SNAPSHOT + + 4.0.0 + + product-common + + + + org.projectlombok + lombok + + + + \ No newline at end of file diff --git a/product/src/main/java/cn/algerfan/product/server/common/DecreaseStockOutput.java b/product/product-common/src/main/java/cn/algerfan/product/common/DecreaseStockOutput.java similarity index 85% rename from product/src/main/java/cn/algerfan/product/server/common/DecreaseStockOutput.java rename to product/product-common/src/main/java/cn/algerfan/product/common/DecreaseStockOutput.java index 46ede32..76fd794 100755 --- a/product/src/main/java/cn/algerfan/product/server/common/DecreaseStockOutput.java +++ b/product/product-common/src/main/java/cn/algerfan/product/common/DecreaseStockOutput.java @@ -1,4 +1,4 @@ -package cn.algerfan.product.server.common; +package cn.algerfan.product.common; import lombok.Data; diff --git a/product/src/main/java/cn/algerfan/product/server/common/ProductInfoOutput.java b/product/product-common/src/main/java/cn/algerfan/product/common/ProductInfoOutput.java similarity index 88% rename from product/src/main/java/cn/algerfan/product/server/common/ProductInfoOutput.java rename to product/product-common/src/main/java/cn/algerfan/product/common/ProductInfoOutput.java index 223615d..d1657d5 100755 --- a/product/src/main/java/cn/algerfan/product/server/common/ProductInfoOutput.java +++ b/product/product-common/src/main/java/cn/algerfan/product/common/ProductInfoOutput.java @@ -1,4 +1,4 @@ -package cn.algerfan.product.server.common; +package cn.algerfan.product.common; import lombok.Data; diff --git a/product/product-server/pom.xml b/product/product-server/pom.xml new file mode 100644 index 0000000..1171993 --- /dev/null +++ b/product/product-server/pom.xml @@ -0,0 +1,62 @@ + + + + product + cn.algerfan + 0.0.1-SNAPSHOT + + 4.0.0 + + product-server + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + mysql + mysql-connector-java + + + org.projectlombok + lombok + + + cn.algerfan + 0.0.1-SNAPSHOT + product-common + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + \ No newline at end of file diff --git a/product/src/main/java/cn/algerfan/product/server/ProductApplication.java b/product/product-server/src/main/java/cn/algerfan/product/server/ProductApplication.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/ProductApplication.java rename to product/product-server/src/main/java/cn/algerfan/product/server/ProductApplication.java diff --git a/product/src/main/java/cn/algerfan/product/server/controller/ProductController.java b/product/product-server/src/main/java/cn/algerfan/product/server/controller/ProductController.java similarity index 93% rename from product/src/main/java/cn/algerfan/product/server/controller/ProductController.java rename to product/product-server/src/main/java/cn/algerfan/product/server/controller/ProductController.java index 5ebf761..a849ce8 100755 --- a/product/src/main/java/cn/algerfan/product/server/controller/ProductController.java +++ b/product/product-server/src/main/java/cn/algerfan/product/server/controller/ProductController.java @@ -1,7 +1,7 @@ package cn.algerfan.product.server.controller; -import cn.algerfan.product.server.common.DecreaseStockOutput; -import cn.algerfan.product.server.common.ProductInfoOutput; +import cn.algerfan.product.common.DecreaseStockOutput; +import cn.algerfan.product.common.ProductInfoOutput; import cn.algerfan.product.server.domain.ProductCategory; import cn.algerfan.product.server.domain.ProductInfo; import cn.algerfan.product.server.service.ProductCategoryService; diff --git a/product/src/main/java/cn/algerfan/product/server/domain/ProductCategory.java b/product/product-server/src/main/java/cn/algerfan/product/server/domain/ProductCategory.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/domain/ProductCategory.java rename to product/product-server/src/main/java/cn/algerfan/product/server/domain/ProductCategory.java diff --git a/product/src/main/java/cn/algerfan/product/server/domain/ProductInfo.java b/product/product-server/src/main/java/cn/algerfan/product/server/domain/ProductInfo.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/domain/ProductInfo.java rename to product/product-server/src/main/java/cn/algerfan/product/server/domain/ProductInfo.java diff --git a/product/src/main/java/cn/algerfan/product/server/enums/ProductStatusEnum.java b/product/product-server/src/main/java/cn/algerfan/product/server/enums/ProductStatusEnum.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/enums/ProductStatusEnum.java rename to product/product-server/src/main/java/cn/algerfan/product/server/enums/ProductStatusEnum.java diff --git a/product/src/main/java/cn/algerfan/product/server/enums/ResultEnum.java b/product/product-server/src/main/java/cn/algerfan/product/server/enums/ResultEnum.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/enums/ResultEnum.java rename to product/product-server/src/main/java/cn/algerfan/product/server/enums/ResultEnum.java diff --git a/product/src/main/java/cn/algerfan/product/server/exception/ProductException.java b/product/product-server/src/main/java/cn/algerfan/product/server/exception/ProductException.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/exception/ProductException.java rename to product/product-server/src/main/java/cn/algerfan/product/server/exception/ProductException.java diff --git a/product/src/main/java/cn/algerfan/product/server/repository/ProductCategoryRepository.java b/product/product-server/src/main/java/cn/algerfan/product/server/repository/ProductCategoryRepository.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/repository/ProductCategoryRepository.java rename to product/product-server/src/main/java/cn/algerfan/product/server/repository/ProductCategoryRepository.java diff --git a/product/src/main/java/cn/algerfan/product/server/repository/ProductInfoRepository.java b/product/product-server/src/main/java/cn/algerfan/product/server/repository/ProductInfoRepository.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/repository/ProductInfoRepository.java rename to product/product-server/src/main/java/cn/algerfan/product/server/repository/ProductInfoRepository.java diff --git a/product/src/main/java/cn/algerfan/product/server/service/ProductCategoryService.java b/product/product-server/src/main/java/cn/algerfan/product/server/service/ProductCategoryService.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/service/ProductCategoryService.java rename to product/product-server/src/main/java/cn/algerfan/product/server/service/ProductCategoryService.java diff --git a/product/src/main/java/cn/algerfan/product/server/service/ProductService.java b/product/product-server/src/main/java/cn/algerfan/product/server/service/ProductService.java similarity index 80% rename from product/src/main/java/cn/algerfan/product/server/service/ProductService.java rename to product/product-server/src/main/java/cn/algerfan/product/server/service/ProductService.java index 19e8147..23d62ee 100755 --- a/product/src/main/java/cn/algerfan/product/server/service/ProductService.java +++ b/product/product-server/src/main/java/cn/algerfan/product/server/service/ProductService.java @@ -1,7 +1,7 @@ package cn.algerfan.product.server.service; -import cn.algerfan.product.server.common.DecreaseStockOutput; -import cn.algerfan.product.server.common.ProductInfoOutput; +import cn.algerfan.product.common.DecreaseStockOutput; +import cn.algerfan.product.common.ProductInfoOutput; import cn.algerfan.product.server.domain.ProductInfo; import java.util.List; diff --git a/product/src/main/java/cn/algerfan/product/server/service/impl/ProductCategoryServiceImpl.java b/product/product-server/src/main/java/cn/algerfan/product/server/service/impl/ProductCategoryServiceImpl.java similarity index 96% rename from product/src/main/java/cn/algerfan/product/server/service/impl/ProductCategoryServiceImpl.java rename to product/product-server/src/main/java/cn/algerfan/product/server/service/impl/ProductCategoryServiceImpl.java index 47f2580..389dd7e 100755 --- a/product/src/main/java/cn/algerfan/product/server/service/impl/ProductCategoryServiceImpl.java +++ b/product/product-server/src/main/java/cn/algerfan/product/server/service/impl/ProductCategoryServiceImpl.java @@ -1,8 +1,8 @@ package cn.algerfan.product.server.service.impl; import cn.algerfan.product.server.domain.ProductCategory; -import cn.algerfan.product.server.repository.ProductCategoryRepository; import cn.algerfan.product.server.service.ProductCategoryService; +import cn.algerfan.product.server.repository.ProductCategoryRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/product/src/main/java/cn/algerfan/product/server/service/impl/ProductServiceImpl.java b/product/product-server/src/main/java/cn/algerfan/product/server/service/impl/ProductServiceImpl.java similarity index 93% rename from product/src/main/java/cn/algerfan/product/server/service/impl/ProductServiceImpl.java rename to product/product-server/src/main/java/cn/algerfan/product/server/service/impl/ProductServiceImpl.java index f15a5e5..282467f 100755 --- a/product/src/main/java/cn/algerfan/product/server/service/impl/ProductServiceImpl.java +++ b/product/product-server/src/main/java/cn/algerfan/product/server/service/impl/ProductServiceImpl.java @@ -1,12 +1,12 @@ package cn.algerfan.product.server.service.impl; -import cn.algerfan.product.server.common.DecreaseStockOutput; -import cn.algerfan.product.server.common.ProductInfoOutput; -import cn.algerfan.product.server.exception.ProductException; -import cn.algerfan.product.server.repository.ProductInfoRepository; +import cn.algerfan.product.common.DecreaseStockOutput; +import cn.algerfan.product.common.ProductInfoOutput; import cn.algerfan.product.server.domain.ProductInfo; import cn.algerfan.product.server.enums.ProductStatusEnum; import cn.algerfan.product.server.enums.ResultEnum; +import cn.algerfan.product.server.exception.ProductException; +import cn.algerfan.product.server.repository.ProductInfoRepository; import cn.algerfan.product.server.service.ProductService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; diff --git a/product/src/main/java/cn/algerfan/product/server/util/ResultVoUtil.java b/product/product-server/src/main/java/cn/algerfan/product/server/util/ResultVoUtil.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/util/ResultVoUtil.java rename to product/product-server/src/main/java/cn/algerfan/product/server/util/ResultVoUtil.java diff --git a/product/src/main/java/cn/algerfan/product/server/vo/ProductInfoVo.java b/product/product-server/src/main/java/cn/algerfan/product/server/vo/ProductInfoVo.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/vo/ProductInfoVo.java rename to product/product-server/src/main/java/cn/algerfan/product/server/vo/ProductInfoVo.java diff --git a/product/src/main/java/cn/algerfan/product/server/vo/ProductVo.java b/product/product-server/src/main/java/cn/algerfan/product/server/vo/ProductVo.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/vo/ProductVo.java rename to product/product-server/src/main/java/cn/algerfan/product/server/vo/ProductVo.java diff --git a/product/src/main/java/cn/algerfan/product/server/vo/ResultVo.java b/product/product-server/src/main/java/cn/algerfan/product/server/vo/ResultVo.java similarity index 100% rename from product/src/main/java/cn/algerfan/product/server/vo/ResultVo.java rename to product/product-server/src/main/java/cn/algerfan/product/server/vo/ResultVo.java diff --git a/product/src/main/resources/application.yml b/product/product-server/src/main/resources/application.yml similarity index 100% rename from product/src/main/resources/application.yml rename to product/product-server/src/main/resources/application.yml diff --git a/product/src/test/java/cn/algerfan/product/server/ProductApplicationTests.java b/product/product-server/src/test/java/cn/algerfan/product/server/ProductApplicationTests.java similarity index 100% rename from product/src/test/java/cn/algerfan/product/server/ProductApplicationTests.java rename to product/product-server/src/test/java/cn/algerfan/product/server/ProductApplicationTests.java diff --git a/product/src/test/java/cn/algerfan/product/server/repository/ProductCategoryRepositoryTest.java b/product/product-server/src/test/java/cn/algerfan/product/server/repository/ProductCategoryRepositoryTest.java similarity index 100% rename from product/src/test/java/cn/algerfan/product/server/repository/ProductCategoryRepositoryTest.java rename to product/product-server/src/test/java/cn/algerfan/product/server/repository/ProductCategoryRepositoryTest.java diff --git a/product/src/test/java/cn/algerfan/product/server/repository/ProductInfoRepositoryTest.java b/product/product-server/src/test/java/cn/algerfan/product/server/repository/ProductInfoRepositoryTest.java similarity index 100% rename from product/src/test/java/cn/algerfan/product/server/repository/ProductInfoRepositoryTest.java rename to product/product-server/src/test/java/cn/algerfan/product/server/repository/ProductInfoRepositoryTest.java diff --git a/product/src/test/java/cn/algerfan/product/server/service/ProductCategoryServiceTest.java b/product/product-server/src/test/java/cn/algerfan/product/server/service/ProductCategoryServiceTest.java similarity index 100% rename from product/src/test/java/cn/algerfan/product/server/service/ProductCategoryServiceTest.java rename to product/product-server/src/test/java/cn/algerfan/product/server/service/ProductCategoryServiceTest.java diff --git a/product/src/test/java/cn/algerfan/product/server/service/ProductServiceImplTest.java b/product/product-server/src/test/java/cn/algerfan/product/server/service/ProductServiceImplTest.java similarity index 91% rename from product/src/test/java/cn/algerfan/product/server/service/ProductServiceImplTest.java rename to product/product-server/src/test/java/cn/algerfan/product/server/service/ProductServiceImplTest.java index 32d17b4..16a4218 100755 --- a/product/src/test/java/cn/algerfan/product/server/service/ProductServiceImplTest.java +++ b/product/product-server/src/test/java/cn/algerfan/product/server/service/ProductServiceImplTest.java @@ -1,7 +1,7 @@ package cn.algerfan.product.server.service; -import cn.algerfan.product.server.common.DecreaseStockOutput; -import cn.algerfan.product.server.common.ProductInfoOutput; +import cn.algerfan.product.common.DecreaseStockOutput; +import cn.algerfan.product.common.ProductInfoOutput; import cn.algerfan.product.server.domain.ProductInfo; import org.junit.Assert; import org.junit.Test;