Skip to content

Commit c148c61

Browse files
committed
add mall-tiny-smart-doc
1 parent 020c9b7 commit c148c61

32 files changed

+2837
-0
lines changed

mall-tiny-smart-doc/.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
HELP.md
2+
/target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
5+
### STS ###
6+
.apt_generated
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
12+
.sts4-cache
13+
14+
### IntelliJ IDEA ###
15+
.idea
16+
*.iws
17+
*.iml
18+
*.ipr
19+
20+
### NetBeans ###
21+
/nbproject/private/
22+
/nbbuild/
23+
/dist/
24+
/nbdist/
25+
/.nb-gradle/
26+
/build/
27+
28+
### VS Code ###
29+
.vscode/
30+
31+
### smart-doc ###
32+
/src/main/resources/static/doc/

mall-tiny-smart-doc/pom.xml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.macro.mall</groupId>
6+
<artifactId>mall-tiny-smart-doc</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<name>mall-tiny-smart-doc</name>
9+
<description>Demo project for Spring Boot</description>
10+
11+
<properties>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
14+
<java.version>1.8</java.version>
15+
<skipTests>true</skipTests>
16+
</properties>
17+
18+
<parent>
19+
<groupId>org.springframework.boot</groupId>
20+
<artifactId>spring-boot-starter-parent</artifactId>
21+
<version>2.2.0.RELEASE</version>
22+
<relativePath/> <!-- lookup parent from repository -->
23+
</parent>
24+
<dependencies>
25+
<!--SpringBoot通用依赖模块-->
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter-web</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-starter-actuator</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-starter-aop</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-starter-test</artifactId>
41+
<scope>test</scope>
42+
</dependency>
43+
<!--MyBatis分页插件-->
44+
<dependency>
45+
<groupId>com.github.pagehelper</groupId>
46+
<artifactId>pagehelper-spring-boot-starter</artifactId>
47+
<version>1.2.10</version>
48+
</dependency>
49+
<!--集成druid连接池-->
50+
<dependency>
51+
<groupId>com.alibaba</groupId>
52+
<artifactId>druid-spring-boot-starter</artifactId>
53+
<version>1.1.10</version>
54+
</dependency>
55+
<!-- MyBatis 生成器 -->
56+
<dependency>
57+
<groupId>org.mybatis.generator</groupId>
58+
<artifactId>mybatis-generator-core</artifactId>
59+
<version>1.3.3</version>
60+
</dependency>
61+
<!--Mysql数据库驱动-->
62+
<dependency>
63+
<groupId>mysql</groupId>
64+
<artifactId>mysql-connector-java</artifactId>
65+
<version>8.0.15</version>
66+
</dependency>
67+
<!--lombok依赖-->
68+
<dependency>
69+
<groupId>org.projectlombok</groupId>
70+
<artifactId>lombok</artifactId>
71+
<optional>true</optional>
72+
</dependency>
73+
<!--SpringSecurity依赖配置-->
74+
<dependency>
75+
<groupId>org.springframework.boot</groupId>
76+
<artifactId>spring-boot-starter-security</artifactId>
77+
</dependency>
78+
<!--Hutool Java工具包-->
79+
<dependency>
80+
<groupId>cn.hutool</groupId>
81+
<artifactId>hutool-all</artifactId>
82+
<version>4.5.7</version>
83+
</dependency>
84+
<!--JWT(Json Web Token)登录支持-->
85+
<dependency>
86+
<groupId>io.jsonwebtoken</groupId>
87+
<artifactId>jjwt</artifactId>
88+
<version>0.9.0</version>
89+
</dependency>
90+
91+
</dependencies>
92+
93+
<build>
94+
<plugins>
95+
<plugin>
96+
<groupId>org.springframework.boot</groupId>
97+
<artifactId>spring-boot-maven-plugin</artifactId>
98+
</plugin>
99+
<plugin>
100+
<groupId>com.github.shalousun</groupId>
101+
<artifactId>smart-doc-maven-plugin</artifactId>
102+
<version>2.2.8</version>
103+
<configuration>
104+
<!--指定smart-doc使用的配置文件路径-->
105+
<configFile>./src/main/resources/smart-doc.json</configFile>
106+
<!--指定项目名称-->
107+
<projectName>mall-tiny-smart-doc</projectName>
108+
</configuration>
109+
</plugin>
110+
</plugins>
111+
</build>
112+
113+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.macro.mall.tiny;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class MallTinyApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(MallTinyApplication.class, args);
11+
}
12+
13+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.macro.mall.tiny.common.api;
2+
3+
import com.github.pagehelper.PageInfo;
4+
5+
import java.util.List;
6+
7+
/**
8+
* 分页数据封装类
9+
* Created by macro on 2019/4/19.
10+
*/
11+
public class CommonPage<T> {
12+
private Integer pageNum;
13+
private Integer pageSize;
14+
private Integer totalPage;
15+
private Long total;
16+
private List<T> list;
17+
18+
/**
19+
* 将PageHelper分页后的list转为分页信息
20+
*/
21+
public static <T> CommonPage<T> restPage(List<T> list) {
22+
CommonPage<T> result = new CommonPage<T>();
23+
PageInfo<T> pageInfo = new PageInfo<T>(list);
24+
result.setTotalPage(pageInfo.getPages());
25+
result.setPageNum(pageInfo.getPageNum());
26+
result.setPageSize(pageInfo.getPageSize());
27+
result.setTotal(pageInfo.getTotal());
28+
result.setList(pageInfo.getList());
29+
return result;
30+
}
31+
32+
public Integer getPageNum() {
33+
return pageNum;
34+
}
35+
36+
public void setPageNum(Integer pageNum) {
37+
this.pageNum = pageNum;
38+
}
39+
40+
public Integer getPageSize() {
41+
return pageSize;
42+
}
43+
44+
public void setPageSize(Integer pageSize) {
45+
this.pageSize = pageSize;
46+
}
47+
48+
public Integer getTotalPage() {
49+
return totalPage;
50+
}
51+
52+
public void setTotalPage(Integer totalPage) {
53+
this.totalPage = totalPage;
54+
}
55+
56+
public List<T> getList() {
57+
return list;
58+
}
59+
60+
public void setList(List<T> list) {
61+
this.list = list;
62+
}
63+
64+
public Long getTotal() {
65+
return total;
66+
}
67+
68+
public void setTotal(Long total) {
69+
this.total = total;
70+
}
71+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package com.macro.mall.tiny.common.api;
2+
3+
/**
4+
* 通用返回对象
5+
* Created by macro on 2019/4/19.
6+
*/
7+
public class CommonResult<T> {
8+
/**
9+
* 响应码
10+
*/
11+
private long code;
12+
/**
13+
* 相应消息
14+
*/
15+
private String message;
16+
/**
17+
* 返回数据
18+
*/
19+
private T data;
20+
21+
protected CommonResult() {
22+
}
23+
24+
protected CommonResult(long code, String message, T data) {
25+
this.code = code;
26+
this.message = message;
27+
this.data = data;
28+
}
29+
30+
/**
31+
* 成功返回结果
32+
*
33+
* @param data 获取的数据
34+
*/
35+
public static <T> CommonResult<T> success(T data) {
36+
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data);
37+
}
38+
39+
/**
40+
* 成功返回结果
41+
*
42+
* @param data 获取的数据
43+
* @param message 提示信息
44+
*/
45+
public static <T> CommonResult<T> success(T data, String message) {
46+
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), message, data);
47+
}
48+
49+
/**
50+
* 失败返回结果
51+
* @param errorCode 错误码
52+
*/
53+
public static <T> CommonResult<T> failed(IErrorCode errorCode) {
54+
return new CommonResult<T>(errorCode.getCode(), errorCode.getMessage(), null);
55+
}
56+
57+
/**
58+
* 失败返回结果
59+
* @param message 提示信息
60+
*/
61+
public static <T> CommonResult<T> failed(String message) {
62+
return new CommonResult<T>(ResultCode.FAILED.getCode(), message, null);
63+
}
64+
65+
/**
66+
* 失败返回结果
67+
*/
68+
public static <T> CommonResult<T> failed() {
69+
return failed(ResultCode.FAILED);
70+
}
71+
72+
/**
73+
* 参数验证失败返回结果
74+
*/
75+
public static <T> CommonResult<T> validateFailed() {
76+
return failed(ResultCode.VALIDATE_FAILED);
77+
}
78+
79+
/**
80+
* 参数验证失败返回结果
81+
* @param message 提示信息
82+
*/
83+
public static <T> CommonResult<T> validateFailed(String message) {
84+
return new CommonResult<T>(ResultCode.VALIDATE_FAILED.getCode(), message, null);
85+
}
86+
87+
/**
88+
* 未登录返回结果
89+
*/
90+
public static <T> CommonResult<T> unauthorized(T data) {
91+
return new CommonResult<T>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getMessage(), data);
92+
}
93+
94+
/**
95+
* 未授权返回结果
96+
*/
97+
public static <T> CommonResult<T> forbidden(T data) {
98+
return new CommonResult<T>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getMessage(), data);
99+
}
100+
101+
public long getCode() {
102+
return code;
103+
}
104+
105+
public void setCode(long code) {
106+
this.code = code;
107+
}
108+
109+
public String getMessage() {
110+
return message;
111+
}
112+
113+
public void setMessage(String message) {
114+
this.message = message;
115+
}
116+
117+
public T getData() {
118+
return data;
119+
}
120+
121+
public void setData(T data) {
122+
this.data = data;
123+
}
124+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.macro.mall.tiny.common.api;
2+
3+
/**
4+
* 封装API的错误码
5+
* Created by macro on 2019/4/19.
6+
*/
7+
public interface IErrorCode {
8+
long getCode();
9+
10+
String getMessage();
11+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.macro.mall.tiny.common.api;
2+
3+
/**
4+
* 枚举了一些常用API操作码
5+
* Created by macro on 2019/4/19.
6+
*/
7+
public enum ResultCode implements IErrorCode {
8+
SUCCESS(200, "操作成功"),
9+
FAILED(500, "操作失败"),
10+
VALIDATE_FAILED(404, "参数检验失败"),
11+
UNAUTHORIZED(401, "暂未登录或token已经过期"),
12+
FORBIDDEN(403, "没有相关权限");
13+
private long code;
14+
private String message;
15+
16+
private ResultCode(long code, String message) {
17+
this.code = code;
18+
this.message = message;
19+
}
20+
21+
public long getCode() {
22+
return code;
23+
}
24+
25+
public String getMessage() {
26+
return message;
27+
}
28+
}

0 commit comments

Comments
 (0)