forked from xkcoding/spring-boot-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
2,885 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
|
||
### 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/ | ||
|
||
### VS Code ### | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>spring-boot-demo-codegen</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>spring-boot-demo-codegen</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<parent> | ||
<groupId>com.xkcoding</groupId> | ||
<artifactId>spring-boot-demo</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-tomcat</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-undertow</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.zaxxer</groupId> | ||
<artifactId>HikariCP</artifactId> | ||
</dependency> | ||
|
||
<!--velocity代码生成使用模板 --> | ||
<dependency> | ||
<groupId>org.apache.velocity</groupId> | ||
<artifactId>velocity</artifactId> | ||
<version>1.7</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-text</artifactId> | ||
<version>1.6</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>cn.hutool</groupId> | ||
<artifactId>hutool-all</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>spring-boot-demo-codegen</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
26 changes: 26 additions & 0 deletions
26
...oot-demo-codegen/src/main/java/com/xkcoding/codegen/SpringBootDemoCodegenApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.xkcoding.codegen; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* <p> | ||
* 启动器 | ||
* </p> | ||
* | ||
* @package: com.xkcoding.codegen | ||
* @description: 启动器 | ||
* @author: yangkai.shen | ||
* @date: Created in 2019-03-22 09:10 | ||
* @copyright: Copyright (c) 2019 | ||
* @version: V1.0 | ||
* @modified: yangkai.shen | ||
*/ | ||
@SpringBootApplication | ||
public class SpringBootDemoCodegenApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringBootDemoCodegenApplication.class, args); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
spring-boot-demo-codegen/src/main/java/com/xkcoding/codegen/common/IResultCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.xkcoding.codegen.common; | ||
|
||
/** | ||
* <p> | ||
* 统一状态码接口 | ||
* </p> | ||
* | ||
* @package: com.xkcoding.rbac.shiro.common | ||
* @description: 统一状态码接口 | ||
* @author: yangkai.shen | ||
* @date: Created in 2019-03-21 16:28 | ||
* @copyright: Copyright (c) 2019 | ||
* @version: V1.0 | ||
* @modified: yangkai.shen | ||
*/ | ||
public interface IResultCode { | ||
/** | ||
* 获取状态码 | ||
* | ||
* @return 状态码 | ||
*/ | ||
Integer getCode(); | ||
|
||
/** | ||
* 获取返回消息 | ||
* | ||
* @return 返回消息 | ||
*/ | ||
String getMessage(); | ||
} |
43 changes: 43 additions & 0 deletions
43
spring-boot-demo-codegen/src/main/java/com/xkcoding/codegen/common/PageResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.xkcoding.codegen.common; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* <p> | ||
* 分页结果集 | ||
* </p> | ||
* | ||
* @package: com.xkcoding.codegen.common | ||
* @description: 分页结果集 | ||
* @author: yangkai.shen | ||
* @date: Created in 2019-03-22 11:24 | ||
* @copyright: Copyright (c) 2019 | ||
* @version: V1.0 | ||
* @modified: yangkai.shen | ||
*/ | ||
@Data | ||
@AllArgsConstructor | ||
public class PageResult<T> { | ||
/** | ||
* 总条数 | ||
*/ | ||
private Long total; | ||
|
||
/** | ||
* 页码 | ||
*/ | ||
private int pageNumber; | ||
|
||
/** | ||
* 每页结果数 | ||
*/ | ||
private int pageSize; | ||
|
||
/** | ||
* 结果集 | ||
*/ | ||
private List<T> list; | ||
} |
95 changes: 95 additions & 0 deletions
95
spring-boot-demo-codegen/src/main/java/com/xkcoding/codegen/common/R.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.xkcoding.codegen.common; | ||
|
||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* <p> | ||
* 统一API对象返回 | ||
* </p> | ||
* | ||
* @package: com.xkcoding.codegen.common | ||
* @description: 统一API对象返回 | ||
* @author: yangkai.shen | ||
* @date: Created in 2019-03-22 10:13 | ||
* @copyright: Copyright (c) 2019 | ||
* @version: V1.0 | ||
* @modified: yangkai.shen | ||
*/ | ||
@Data | ||
@NoArgsConstructor | ||
public class R<T> { | ||
/** | ||
* 状态码 | ||
*/ | ||
private Integer code; | ||
|
||
/** | ||
* 返回消息 | ||
*/ | ||
private String message; | ||
|
||
/** | ||
* 状态 | ||
*/ | ||
private boolean status; | ||
|
||
/** | ||
* 返回数据 | ||
*/ | ||
private T data; | ||
|
||
public R(Integer code, String message, boolean status, T data) { | ||
this.code = code; | ||
this.message = message; | ||
this.status = status; | ||
this.data = data; | ||
} | ||
|
||
public R(IResultCode resultCode, boolean status, T data) { | ||
this.code = resultCode.getCode(); | ||
this.message = resultCode.getMessage(); | ||
this.status = status; | ||
this.data = data; | ||
} | ||
|
||
public R(IResultCode resultCode, boolean status) { | ||
this.code = resultCode.getCode(); | ||
this.message = resultCode.getMessage(); | ||
this.status = status; | ||
this.data = null; | ||
} | ||
|
||
public static <T> R success() { | ||
return new R<>(ResultCode.OK, true); | ||
} | ||
|
||
public static <T> R message(String message) { | ||
return new R<>(ResultCode.OK.getCode(), message, true, null); | ||
} | ||
|
||
public static <T> R success(T data) { | ||
return new R<>(ResultCode.OK, true, data); | ||
} | ||
|
||
public static <T> R fail() { | ||
return new R<>(ResultCode.ERROR, false); | ||
} | ||
|
||
public static <T> R fail(IResultCode resultCode) { | ||
return new R<>(resultCode, false); | ||
} | ||
|
||
public static <T> R fail(Integer code, String message) { | ||
return new R<>(code, message, false, null); | ||
} | ||
|
||
public static <T> R fail(IResultCode resultCode, T data) { | ||
return new R<>(resultCode, false, data); | ||
} | ||
|
||
public static <T> R fail(Integer code, String message, T data) { | ||
return new R<>(code, message, false, data); | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
spring-boot-demo-codegen/src/main/java/com/xkcoding/codegen/common/ResultCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.xkcoding.codegen.common; | ||
|
||
import lombok.Getter; | ||
|
||
/** | ||
* <p> | ||
* 通用状态枚举 | ||
* </p> | ||
* | ||
* @package: com.xkcoding.codegen.common | ||
* @description: 通用状态枚举 | ||
* @author: yangkai.shen | ||
* @date: Created in 2019-03-22 10:13 | ||
* @copyright: Copyright (c) 2019 | ||
* @version: V1.0 | ||
* @modified: yangkai.shen | ||
*/ | ||
@Getter | ||
public enum ResultCode implements IResultCode { | ||
/** | ||
* 成功 | ||
*/ | ||
OK(200, "成功"), | ||
/** | ||
* 失败 | ||
*/ | ||
ERROR(500, "失败"); | ||
|
||
/** | ||
* 返回码 | ||
*/ | ||
private Integer code; | ||
|
||
/** | ||
* 返回消息 | ||
*/ | ||
private String message; | ||
|
||
ResultCode(Integer code, String message) { | ||
this.code = code; | ||
this.message = message; | ||
} | ||
|
||
} |
Oops, something went wrong.