Skip to content

Commit db2c2e8

Browse files
author
wj596
committed
V0.0.3
1 parent 4912ab0 commit db2c2e8

18 files changed

+428
-388
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
11
# fastboot生产级快速开发脚手架
2-
**极简.严谨.优雅**
2+
**极简.规范.优雅**
33

44

55
fastboot是一套围绕着springboot技术栈的脚手架系统,用于快速开发基于spring的web项目
66

7+
目录结构:
8+
9+
1、fb-common 公共工具
10+
11+
2、fb-frame 框架层
12+
13+
3、fb-generator 代码生成器
14+
15+
4、fb-plugs 插件包
16+
17+
multipleds 多数据源组件
18+
19+
security 安全组件
20+
21+
5、fb-web web脚手架
22+
23+
6、fb-kotlin-web web脚手架(kotlin版本)
24+
25+
726
后端:
27+
828
springboot 2.5.0
929
mybatis-plus 3.4.2
1030
druid 1.2.6
1131
前端:
32+
1233
vite
1334
vue3
1435
antd
1536
16-
目前正在开发中
37+
38+
目前正在开发中 。。。 。。。
1739

1840
1941

frame/src/main/java/org/jsets/fastboot/frame/config/BaseConfiguration.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@
1818
* @since 0.1
1919
*/
2020
@Configuration
21-
public class BaseConfiguration implements ApplicationContextAware,EnvironmentAware{
21+
public class BaseConfiguration implements ApplicationContextAware, EnvironmentAware {
2222

2323
@Override
2424
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
2525
SpringContextHolder.setApplicationContext(applicationContext);
2626
}
27-
27+
2828
@Override
2929
public void setEnvironment(Environment environment) {
3030
SpringContextHolder.setEnvironment(environment);
3131
}
32-
32+
3333
@Bean
34-
public BaseEntityMetaObjectHandler baseEntityMetaObjectHandler() {
34+
public BaseEntityMetaObjectHandler baseEntityMetaObjectHandler() {
3535
return new BaseEntityMetaObjectHandler();
3636
}
3737

frame/src/main/java/org/jsets/fastboot/frame/config/SwaggerConfiguration.java

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,49 @@
3030
@EnableConfigurationProperties(SwaggerProperties.class)
3131
public class SwaggerConfiguration {
3232

33-
@Bean
34-
public Docket createRestApi(SwaggerProperties properties) {
35-
System.out.println("SwaggerConfiguration createRestApi");
36-
return new Docket(DocumentationType.OAS_30)
37-
.pathMapping("/")
38-
.enable(properties.getEnable())//是否开启swagger,false为关闭
39-
.apiInfo(buildApiInfo(properties)) //设置文档描述信息
40-
.host(properties.getAppDebugAddress())//调试地址
41-
.select()// 选择哪些接口作为swagger的doc发布
42-
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
43-
.paths(PathSelectors.any())
44-
.build()
45-
.protocols(Sets.newHashSet("https", "http"))//协议集合
46-
.securitySchemes(buildSecuritySchemes())//授权信息设置,header token等认证信息
47-
.securityContexts(buildSecurityContexts());// 全局授权信息
48-
}
33+
@Bean
34+
public Docket createRestApi(SwaggerProperties properties) {
35+
System.out.println("SwaggerConfiguration createRestApi");
36+
return new Docket(DocumentationType.OAS_30).pathMapping("/").enable(properties.getEnable())// 是否开启swagger,false为关闭
37+
.apiInfo(buildApiInfo(properties)) // 设置文档描述信息
38+
.host(properties.getAppDebugAddress())// 调试地址
39+
.select()// 选择哪些接口作为swagger的doc发布
40+
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).paths(PathSelectors.any())
41+
.build().protocols(Sets.newHashSet("https", "http"))// 协议集合
42+
.securitySchemes(buildSecuritySchemes())// 授权信息设置,header token等认证信息
43+
.securityContexts(buildSecurityContexts());// 全局授权信息
44+
}
4945

50-
/**
51-
* 文档描述信息
52-
*/
53-
private ApiInfo buildApiInfo(SwaggerProperties properties) {
54-
ApiInfoBuilder builder = new ApiInfoBuilder()
55-
.title(properties.getAppName() + " Api Doc")
56-
.description(properties.getAppDesc())
57-
.version("Application Version: " + properties.getAppVersion() + ", Spring Boot Version: " + SpringBootVersion.getVersion());
58-
if(StringUtils.notEmpty(properties.getContactName())
59-
||StringUtils.notEmpty(properties.getContactUrl())
60-
||StringUtils.notEmpty(properties.getContactEmail())){
61-
builder.contact(new Contact(properties.getContactName(), properties.getContactUrl(), properties.getContactEmail()));
62-
}
63-
return builder.build();
64-
}
46+
/**
47+
* 文档描述信息
48+
*/
49+
private ApiInfo buildApiInfo(SwaggerProperties properties) {
50+
ApiInfoBuilder builder = new ApiInfoBuilder().title(properties.getAppName() + " Api Doc")
51+
.description(properties.getAppDesc()).version("Application Version: " + properties.getAppVersion()
52+
+ ", Spring Boot Version: " + SpringBootVersion.getVersion());
53+
if (StringUtils.notEmpty(properties.getContactName()) || StringUtils.notEmpty(properties.getContactUrl())
54+
|| StringUtils.notEmpty(properties.getContactEmail())) {
55+
builder.contact(
56+
new Contact(properties.getContactName(), properties.getContactUrl(), properties.getContactEmail()));
57+
}
58+
return builder.build();
59+
}
6560

66-
private List<SecurityScheme> buildSecuritySchemes() {
67-
List<SecurityScheme> ls = Lists.newArrayList();
68-
ls.add(new ApiKey("Authorization", "Authorization", "header"));
69-
return ls;
70-
}
61+
private List<SecurityScheme> buildSecuritySchemes() {
62+
List<SecurityScheme> ls = Lists.newArrayList();
63+
ls.add(new ApiKey("Authorization", "Authorization", "header"));
64+
return ls;
65+
}
7166

72-
/**
73-
* 授权信息全局应用
74-
*/
75-
private List<SecurityContext> buildSecurityContexts() {
76-
SecurityReference securityReference = new SecurityReference("Authorization", new AuthorizationScope[]{new AuthorizationScope("global", "")});
77-
SecurityContext securityContext = SecurityContext.builder().securityReferences(Lists.newArrayList(securityReference)).build();
78-
return Lists.newArrayList(securityContext);
79-
}
67+
/**
68+
* 授权信息全局应用
69+
*/
70+
private List<SecurityContext> buildSecurityContexts() {
71+
SecurityReference securityReference = new SecurityReference("Authorization",
72+
new AuthorizationScope[] { new AuthorizationScope("global", "") });
73+
SecurityContext securityContext = SecurityContext.builder()
74+
.securityReferences(Lists.newArrayList(securityReference)).build();
75+
return Lists.newArrayList(securityContext);
76+
}
8077

8178
}

frame/src/main/java/org/jsets/fastboot/frame/config/SwaggerProperties.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
@ConfigurationProperties(prefix = "fastboot.swagger")
1515
public class SwaggerProperties {
1616

17-
private Boolean enable;//是否开启swagger,生产建议关闭
18-
private String appName;//项目名称
19-
private String appVersion;//项目版本
20-
private String appDesc;//项目描述
21-
private String appDebugAddress;//项目调试地址
22-
private String contactName;//联系人姓名
23-
private String contactUrl;//联系地址
24-
private String contactEmail;//联系人邮件
17+
private Boolean enable;// 是否开启swagger,生产建议关闭
18+
private String appName;// 项目名称
19+
private String appVersion;// 项目版本
20+
private String appDesc;// 项目描述
21+
private String appDebugAddress;// 项目调试地址
22+
private String contactName;// 联系人姓名
23+
private String contactUrl;// 联系地址
24+
private String contactEmail;// 联系人邮件
2525

2626
}

frame/src/main/java/org/jsets/fastboot/frame/controller/BaseController.java

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected <T> Respond failed() {
6363
protected <T> Respond failed(String message) {
6464
return Respond.fail(message);
6565
}
66-
66+
6767
/**
6868
* 操作失败
6969
*
@@ -82,45 +82,42 @@ protected <T> DataResp<T> dataResp(T t) {
8282
respond.setResult(t);
8383
return respond;
8484
}
85-
85+
8686
/**
8787
* 单条数据响应失败
8888
*/
8989
protected <T> DataResp<T> dataRespFail() {
9090
return DataResp.fail();
9191
}
92-
92+
9393
/**
9494
* 单条数据响应失败
9595
*/
9696
protected <T> DataResp<T> dataRespFail(String message) {
9797
return DataResp.fail(message);
9898
}
99-
100-
99+
101100
/**
102101
* 返回数据列表
103102
*/
104103
protected <T> ListResp<T> listResp(List<T> ls) {
105104
return ListResp.ok();
106105
}
107-
108-
106+
109107
/**
110108
* 数据列表响应失败
111109
*/
112110
protected <T> ListResp<T> listRespFail() {
113111
return ListResp.fail();
114112
}
115-
113+
116114
/**
117115
* 数据列表响应失败
118116
*/
119117
protected <T> ListResp<T> listRespFail(String message) {
120118
return ListResp.fail(message);
121119
}
122-
123-
120+
124121
/**
125122
* 返回分页数据
126123
*/
@@ -130,25 +127,26 @@ protected <T> ListResp<T> pageResp(IPage<T> result) {
130127
respond.setTotal(result.getTotal());
131128
return respond;
132129
}
133-
130+
134131
/**
135132
* 分页数据响应失败
136133
*/
137134
protected <T> ListResp<T> pageResp() {
138135
return this.listRespFail();
139136
}
140-
137+
141138
/**
142139
* 分页数据响应失败
143140
*/
144141
protected <T> ListResp<T> pageResp(String message) {
145142
return this.listRespFail(message);
146143
}
147-
144+
148145
/**
149146
* 参数断言
147+
*
150148
* @param expression 表达式
151-
* @param message 异常消息
149+
* @param message 异常消息
152150
*/
153151
protected void argThat(final boolean expression, final String message) {
154152
if (!expression) {
@@ -158,9 +156,10 @@ protected void argThat(final boolean expression, final String message) {
158156

159157
/**
160158
* 参数断言
159+
*
161160
* @param expression 表达式
162-
* @param formatter 消息格式
163-
* @param args 消息参数
161+
* @param formatter 消息格式
162+
* @param args 消息参数
164163
*/
165164
protected void argThat(final boolean expression, final String formatter, final Object... args) {
166165
if (!expression) {
@@ -170,37 +169,40 @@ protected void argThat(final boolean expression, final String formatter, final O
170169

171170
/**
172171
* 断言参数不为空
173-
* @param argument 参数
172+
*
173+
* @param argument 参数
174174
* @param argumentName 参数名称
175175
*/
176176
protected void argNotNull(final Object argument, final String argumentName) {
177177
if (Objects.isNull(argument)) {
178-
throw new IllegalArgumentException("参数["+argumentName+"],不能为空");
178+
throw new IllegalArgumentException("参数[" + argumentName + "],不能为空");
179179
}
180180
}
181181

182182
/**
183183
* 断言参数不为空字符串
184-
* @param argument 参数
184+
*
185+
* @param argument 参数
185186
* @param argumentName 参数名称
186187
*/
187188
protected void argNotEmpty(final String argument, final String argumentName) {
188189
if (StringUtils.isEmpty(argument)) {
189-
throw new IllegalArgumentException("参数["+argumentName+"],不能为空");
190+
throw new IllegalArgumentException("参数[" + argumentName + "],不能为空");
190191
}
191192
}
192193

193194
/**
194195
* 断言参数不为空白字符串
195-
* @param argument 参数
196+
*
197+
* @param argument 参数
196198
* @param argumentName 参数名称
197199
*/
198200
protected void argNotBlank(final String argument, final String argumentName) {
199201
if (StringUtils.isBlank(argument)) {
200-
throw new IllegalArgumentException("参数["+argumentName+"],不能为空或空白字符串");
202+
throw new IllegalArgumentException("参数[" + argumentName + "],不能为空或空白字符串");
201203
}
202204
}
203-
205+
204206
protected void assertThat(final boolean expression, final RuntimeException exception) {
205207
if (!expression) {
206208
throw exception;

frame/src/main/java/org/jsets/fastboot/frame/controller/ExceptionHandlerAdvice.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ public Respond runtimeUnauthorizedException(RuntimeUnauthorizedException e) {
4343
log.error(e.getMessage(), e);
4444
return Respond.fail(HttpStatus.UNAUTHORIZED, e.getMessage());
4545
}
46-
46+
4747
@ResponseStatus(HttpStatus.FORBIDDEN)
4848
@ExceptionHandler(RuntimeForbiddenException.class)
4949
public Respond runtimeForbiddenException(RuntimeForbiddenException e) {
5050
log.error(e.getMessage(), e);
5151
return Respond.fail(HttpStatus.FORBIDDEN, e.getMessage());
5252
}
53-
53+
5454
@ResponseStatus(HttpStatus.UNAUTHORIZED)
5555
@ExceptionHandler(UnauthorizedException.class)
5656
public Respond authenticationException(UnauthorizedException e) {
@@ -64,7 +64,7 @@ public Respond forbiddenException(ForbiddenException e) {
6464
log.error(e.getMessage(), e);
6565
return Respond.fail(HttpStatus.FORBIDDEN, e.getMessage());
6666
}
67-
67+
6868
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
6969
@ExceptionHandler(value = Exception.class)
7070
public Respond exception(Exception exception) {

0 commit comments

Comments
 (0)