springcloud-04重构(提取重复部分)

一、新建

image

二、POM

<?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>cloud2020</artifactId>
		<groupId>edu.dj.springcloud</groupId>
		<version>1.0-SNAPSHOT</version>
	</parent>
	<modelVersion>4.0.0</modelVersion>

	<artifactId>cloud-api-common</artifactId>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
		</dependency>
		<dependency>
			<groupId>cn.hutool</groupId>
			<artifactId>hutool-all</artifactId>
			<version>5.1.0</version>
		</dependency>
	</dependencies>

</project>

三、entities

image

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T>{
    private Integer code;
    private String message;
    private T data;

    public CommonResult(Integer code, String message){
        this(code, message, null);
    }
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Payment implements Serializable {
    private Long id;
    private String serial;
}

四、maven命令clean install

image

五、支付模块和订单模块修改

5.1 删除原entities

5.2 添加依赖

<!--引入自定义的api-->
<dependency>
	<groupId>edu.dj.springcloud</groupId>
	<artifactId>cloud-api-common</artifactId>
	<version>1.0-SNAPSHOT</version>
</dependency>
posted @ 2021-11-22 19:37  DingJie1024  阅读(40)  评论(0编辑  收藏  举报