Skip to content

Commit

Permalink
✨ spring-boot-demo-codegen 完成
Browse files Browse the repository at this point in the history
  • Loading branch information
xkcoding committed Mar 22, 2019
1 parent c614155 commit 485efde
Show file tree
Hide file tree
Showing 38 changed files with 2,885 additions and 0 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<module>spring-boot-demo-multi-datasource-mybatis</module>
<module>spring-boot-demo-sharding-jdbc</module>
<module>spring-boot-demo-tio</module>
<module>spring-boot-demo-codegen</module>
</modules>
<packaging>pom</packaging>

Expand Down
28 changes: 28 additions & 0 deletions spring-boot-demo-codegen/.gitignore
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/
98 changes: 98 additions & 0 deletions spring-boot-demo-codegen/pom.xml
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>
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);
}

}
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();
}
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;
}
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);
}

}
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;
}

}
Loading

0 comments on commit 485efde

Please sign in to comment.