first can version
This commit is contained in:
33
wdd-common/.gitignore
vendored
Normal file
33
wdd-common/.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
41
wdd-common/pom.xml
Normal file
41
wdd-common/pom.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>ProjectOctopus</artifactId>
|
||||
<groupId>io.wdd</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>io.wdd</groupId>
|
||||
<artifactId>wdd-common</artifactId>
|
||||
|
||||
<version>${project.version}</version>
|
||||
|
||||
<name>wdd-common</name>
|
||||
<description>wdd-common</description>
|
||||
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
|
||||
<!-- <build>-->
|
||||
<!-- <plugins>-->
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <excludes>-->
|
||||
<!-- <exclude>-->
|
||||
<!-- <groupId>org.projectlombok</groupId>-->
|
||||
<!-- <artifactId>lombok</artifactId>-->
|
||||
<!-- </exclude>-->
|
||||
<!-- </excludes>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- </plugin>-->
|
||||
<!-- </plugins>-->
|
||||
<!-- </build>-->
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package io.wdd.wddcommon;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class WddCommonApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(WddCommonApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
49
wdd-common/src/main/java/io/wdd/wddcommon/utils/R.java
Normal file
49
wdd-common/src/main/java/io/wdd/wddcommon/utils/R.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package io.wdd.wddcommon.utils;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class R<T> {
|
||||
|
||||
|
||||
int code;
|
||||
|
||||
String msg;
|
||||
|
||||
T data;
|
||||
|
||||
private R(int code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public R() {
|
||||
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data) {
|
||||
return resetResult(data, ResultStat.SUCCESS);
|
||||
}
|
||||
|
||||
public static <T> R<T> okNoData() {
|
||||
return new R();
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(T data) {
|
||||
return resetResult(data, ResultStat.FAILED);
|
||||
}
|
||||
|
||||
// access from inner
|
||||
private static <T> R<T> resetResult(T data, ResultStat resultStat) {
|
||||
return new R(resultStat.getCode(), resultStat.getDescription(), data);
|
||||
}
|
||||
|
||||
// access to public
|
||||
public static <T> R<T> resetResult(int code, String msg, T data) {
|
||||
return new R<>(code
|
||||
, msg, data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package io.wdd.wddcommon.utils;
|
||||
|
||||
public enum ResultStat {
|
||||
|
||||
SUCCESS(1000, "success"),
|
||||
|
||||
FAILED(5001, "failed"),
|
||||
|
||||
VALIDATE_FAILED(1002, "参数校验失败"),
|
||||
|
||||
PARAM_ERROR(1003, "请求参数错误!"),
|
||||
|
||||
|
||||
|
||||
BAD(5001, "all error !");
|
||||
|
||||
int code;
|
||||
|
||||
String description;
|
||||
|
||||
ResultStat(int code, String description){
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription(){
|
||||
return description;
|
||||
}
|
||||
}
|
||||
1
wdd-common/src/main/resources/application.properties
Normal file
1
wdd-common/src/main/resources/application.properties
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user