Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
ac26b52f
提交
ac26b52f
authored
10月 18, 2022
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修复 swagger default docket 缺失导致 pont 无法正常解析
上级
f1f252f4
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
13 行删除
+20
-13
ExampleController.java
...in/java/com/yiring/app/web/example/ExampleController.java
+13
-6
SwaggerConfig.java
...rc/main/java/com/yiring/common/swagger/SwaggerConfig.java
+7
-7
没有找到文件。
app/src/main/java/com/yiring/app/web/example/ExampleController.java
浏览文件 @
ac26b52f
...
@@ -30,9 +30,7 @@ import org.springframework.core.io.ClassPathResource;
...
@@ -30,9 +30,7 @@ import org.springframework.core.io.ClassPathResource;
import
org.springframework.data.domain.Example
;
import
org.springframework.data.domain.Example
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
/**
* 示例接口
* 示例接口
...
@@ -54,6 +52,7 @@ public class ExampleController {
...
@@ -54,6 +52,7 @@ public class ExampleController {
final
Auths
auths
;
final
Auths
auths
;
final
UserExtensionRepository
userExtensionRepository
;
final
UserExtensionRepository
userExtensionRepository
;
@ApiOperation
(
"Hello World"
)
@GetMapping
@GetMapping
public
Result
<
String
>
hello
()
{
public
Result
<
String
>
hello
()
{
return
Result
.
ok
(
"example.hello"
);
return
Result
.
ok
(
"example.hello"
);
...
@@ -62,15 +61,17 @@ public class ExampleController {
...
@@ -62,15 +61,17 @@ public class ExampleController {
/**
/**
* 测试失败自定义状态信息输出
* 测试失败自定义状态信息输出
*/
*/
@ApiOperation
(
"测试失败"
)
@GetMapping
(
"fail"
)
@GetMapping
(
"fail"
)
public
Result
<
String
>
fail
()
{
public
Result
<
String
>
fail
()
{
throw
BusinessException
.
i18n
(
"Code.100000"
);
throw
BusinessException
.
i18n
(
"Code.100000"
);
}
}
@SaCheckLogin
@SaCheckLogin
@ApiOperation
(
"分页条件查询"
)
@GetMapping
(
"page"
)
@GetMapping
(
"page"
)
public
Result
<
PageVo
<
String
>>
page
(
@Validated
PageParam
pa
gePa
ram
)
{
public
Result
<
PageVo
<
String
>>
page
(
@Validated
PageParam
param
)
{
log
.
info
(
"PageParam: {}"
,
pageP
aram
);
log
.
debug
(
"PageParam: {}"
,
p
aram
);
String
text
=
i18n
.
get
(
"example.hello"
);
String
text
=
i18n
.
get
(
"example.hello"
);
List
<
String
>
data
=
Arrays
.
asList
(
text
.
split
(
" "
));
List
<
String
>
data
=
Arrays
.
asList
(
text
.
split
(
" "
));
...
@@ -78,9 +79,15 @@ public class ExampleController {
...
@@ -78,9 +79,15 @@ public class ExampleController {
return
Result
.
ok
(
vo
);
return
Result
.
ok
(
vo
);
}
}
@ApiOperation
(
value
=
"JSON 传参"
)
@PostMapping
(
"json"
)
public
Result
<
PageVo
<
String
>>
json
(
@RequestBody
@Validated
PageParam
param
)
{
return
page
(
param
);
}
@AuthIgnore
@AuthIgnore
@SneakyThrows
@SneakyThrows
@ApiOperation
(
value
=
"
download
"
,
produces
=
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
)
@ApiOperation
(
value
=
"
文件下载
"
,
produces
=
MediaType
.
APPLICATION_OCTET_STREAM_VALUE
)
@GetMapping
(
"download"
)
@GetMapping
(
"download"
)
public
void
download
(
HttpServletResponse
response
)
{
public
void
download
(
HttpServletResponse
response
)
{
ClassPathResource
resource
=
new
ClassPathResource
(
"static/cat.jpg"
);
ClassPathResource
resource
=
new
ClassPathResource
(
"static/cat.jpg"
);
...
...
basic-common/doc/src/main/java/com/yiring/common/swagger/SwaggerConfig.java
浏览文件 @
ac26b52f
...
@@ -59,29 +59,29 @@ public class SwaggerConfig implements CommandLineRunner {
...
@@ -59,29 +59,29 @@ public class SwaggerConfig implements CommandLineRunner {
@Resource
@Resource
OpenApiExtensionResolver
openApiExtensionResolver
;
OpenApiExtensionResolver
openApiExtensionResolver
;
@Bean
(
name
=
"api.a
ll
"
)
@Bean
(
name
=
"api.a
ny
"
)
public
Docket
a
ll
()
{
public
Docket
a
ny
()
{
return
api
(
"
① 全部
"
,
List
.
of
(
""
),
PathSelectors
.
any
());
return
api
(
"
default
"
,
List
.
of
(
""
),
PathSelectors
.
any
());
}
}
@Bean
(
name
=
"api.auth"
)
@Bean
(
name
=
"api.auth"
)
public
Docket
auth
()
{
public
Docket
auth
()
{
return
api
(
"
②
Auth"
,
List
.
of
(
"com.yiring.auth.web"
),
Predicate
.
not
(
PathSelectors
.
ant
(
path
+
"/sys/**"
)));
return
api
(
"
①
Auth"
,
List
.
of
(
"com.yiring.auth.web"
),
Predicate
.
not
(
PathSelectors
.
ant
(
path
+
"/sys/**"
)));
}
}
@Bean
(
name
=
"api.common"
)
@Bean
(
name
=
"api.common"
)
public
Docket
common
()
{
public
Docket
common
()
{
return
api
(
"
③
公共"
,
List
.
of
(
"com.yiring.common.web"
,
"com.yiring.app.web.common"
),
PathSelectors
.
any
());
return
api
(
"
②
公共"
,
List
.
of
(
"com.yiring.common.web"
,
"com.yiring.app.web.common"
),
PathSelectors
.
any
());
}
}
@Bean
(
name
=
"api.manage"
)
@Bean
(
name
=
"api.manage"
)
public
Docket
manage
()
{
public
Docket
manage
()
{
return
api
(
"
④
系统管理"
,
List
.
of
(
"com.yiring.auth.web.sys"
),
PathSelectors
.
any
());
return
api
(
"
③
系统管理"
,
List
.
of
(
"com.yiring.auth.web.sys"
),
PathSelectors
.
any
());
}
}
@Bean
(
name
=
"api.example"
)
@Bean
(
name
=
"api.example"
)
public
Docket
example
()
{
public
Docket
example
()
{
return
api
(
"
⑤
示例"
,
List
.
of
(
"com.yiring.app.web.example"
),
PathSelectors
.
any
());
return
api
(
"
④
示例"
,
List
.
of
(
"com.yiring.app.web.example"
),
PathSelectors
.
any
());
}
}
private
Docket
api
(
String
group
,
List
<
String
>
basePackages
,
Predicate
<
String
>
paths
)
{
private
Docket
api
(
String
group
,
List
<
String
>
basePackages
,
Predicate
<
String
>
paths
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论