Skip to content

Commit

Permalink
商品服务拆分为多模块
Browse files Browse the repository at this point in the history
  • Loading branch information
AlgerFan committed Aug 26, 2019
1 parent 27a8006 commit 5e6cdd0
Show file tree
Hide file tree
Showing 30 changed files with 165 additions and 57 deletions.
50 changes: 6 additions & 44 deletions product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<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">
<modelVersion>4.0.0</modelVersion>
<modules>
<module>product-server</module>
<module>product-common</module>
<module>product-client</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
Expand All @@ -12,7 +17,7 @@
<groupId>cn.algerfan</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>product</artifactId>
<packaging>jar</packaging>
<packaging>pom</packaging>
<name>product</name>
<description>Demo project for Spring Boot</description>

Expand All @@ -22,40 +27,6 @@
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- TODO 2.0.2.RELEASE需要引入-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
Expand Down Expand Up @@ -106,13 +77,4 @@
</pluginRepository>
</pluginRepositories>-->

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
30 changes: 30 additions & 0 deletions product/product-client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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>cn.algerfan</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>cn.algerfan</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>product-common</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -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<ProductInfoOutput> productInfoList(@RequestBody List<String> productIdList);

/**
* 扣库存
* @param decreaseStockOutputs 传输对象
*/
@PostMapping("/product/decreaseStock")
void decreaseStock(@RequestBody List<DecreaseStockOutput> decreaseStockOutputs);

}
21 changes: 21 additions & 0 deletions product/product-common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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>cn.algerfan</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>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.algerfan.product.server.common;
package cn.algerfan.product.common;

import lombok.Data;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.algerfan.product.server.common;
package cn.algerfan.product.common;

import lombok.Data;

Expand Down
62 changes: 62 additions & 0 deletions product/product-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?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>cn.algerfan</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>product-server</artifactId>

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- TODO 2.0.2.RELEASE需要引入-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>cn.algerfan</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>product-common</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 5e6cdd0

Please sign in to comment.