Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ssssssss-team
magic-api
提交
a6da9a34
M
magic-api
项目概览
ssssssss-team
/
magic-api
12 个月 前同步成功
通知
41
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
magic-api
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a6da9a34
编写于
11月 19, 2021
作者:
M
mxd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
兼容`spring-boot 2.6.0`
上级
c830c9c4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
34 addition
and
18 deletion
+34
-18
magic-api-spring-boot-starter/src/main/java/org/ssssssss/magicapi/spring/boot/starter/MagicAPIAutoConfiguration.java
...gicapi/spring/boot/starter/MagicAPIAutoConfiguration.java
+7
-6
magic-api-spring-boot-starter/src/main/java/org/ssssssss/magicapi/spring/boot/starter/MagicSwaggerConfiguration.java
...gicapi/spring/boot/starter/MagicSwaggerConfiguration.java
+3
-2
magic-api/src/main/java/org/ssssssss/magicapi/adapter/resource/RedisResource.java
...org/ssssssss/magicapi/adapter/resource/RedisResource.java
+2
-3
magic-api/src/main/java/org/ssssssss/magicapi/config/MappingHandlerMapping.java
...a/org/ssssssss/magicapi/config/MappingHandlerMapping.java
+3
-3
magic-api/src/main/java/org/ssssssss/magicapi/utils/Mapping.java
...pi/src/main/java/org/ssssssss/magicapi/utils/Mapping.java
+19
-4
未找到文件。
magic-api-spring-boot-starter/src/main/java/org/ssssssss/magicapi/spring/boot/starter/MagicAPIAutoConfiguration.java
浏览文件 @
a6da9a34
...
...
@@ -274,13 +274,13 @@ public class MagicAPIAutoConfiguration implements WebMvcConfigurer, WebSocketCon
// 配置静态资源路径
registry
.
addResourceHandler
(
web
+
"/**"
).
addResourceLocations
(
"classpath:/magic-editor/"
);
try
{
Mapping
.
create
(
requestMappingHandlerMapping
)
Mapping
mapping
=
Mapping
.
create
(
requestMappingHandlerMapping
);
// 默认首页设置
.
register
(
RequestMappingInfo
.
paths
(
web
).
build
(),
this
,
MagicAPIAutoConfiguration
.
class
.
getDeclaredMethod
(
"redirectIndex"
,
HttpServletRequest
.
class
))
mapping
.
register
(
mapping
.
paths
(
web
).
build
(),
this
,
MagicAPIAutoConfiguration
.
class
.
getDeclaredMethod
(
"redirectIndex"
,
HttpServletRequest
.
class
))
// 读取配置
.
register
(
RequestMappingInfo
.
paths
(
web
+
"/config.json"
).
build
(),
this
,
MagicAPIAutoConfiguration
.
class
.
getDeclaredMethod
(
"readConfig"
))
.
register
(
mapping
.
paths
(
web
+
"/config.json"
).
build
(),
this
,
MagicAPIAutoConfiguration
.
class
.
getDeclaredMethod
(
"readConfig"
))
// 读取配置
.
register
(
RequestMappingInfo
.
paths
(
web
+
"/classes.txt"
).
produces
(
"text/plain"
).
build
(),
this
,
MagicAPIAutoConfiguration
.
class
.
getDeclaredMethod
(
"readClass"
));
.
register
(
mapping
.
paths
(
web
+
"/classes.txt"
).
produces
(
"text/plain"
).
build
(),
this
,
MagicAPIAutoConfiguration
.
class
.
getDeclaredMethod
(
"readClass"
));
}
catch
(
NoSuchMethodException
ignored
)
{
}
}
...
...
@@ -583,9 +583,10 @@ public class MagicAPIAutoConfiguration implements WebMvcConfigurer, WebSocketCon
}
// 注册接收推送的接口
if
(
StringUtils
.
isNotBlank
(
properties
.
getSecretKey
()))
{
RequestMappingInfo
requestMappingInfo
=
RequestMappingInfo
.
paths
(
properties
.
getPushPath
()).
build
();
Mapping
mapping
=
Mapping
.
create
(
requestMappingHandlerMapping
);
RequestMappingInfo
requestMappingInfo
=
mapping
.
paths
(
properties
.
getPushPath
()).
build
();
Method
method
=
MagicWorkbenchController
.
class
.
getDeclaredMethod
(
"receivePush"
,
MultipartFile
.
class
,
String
.
class
,
Long
.
class
,
String
.
class
);
Mapping
.
create
(
requestMappingHandlerMapping
)
.
register
(
requestMappingInfo
,
magicWorkbenchController
,
method
);
mapping
.
register
(
requestMappingInfo
,
magicWorkbenchController
,
method
);
}
// 注册数据源
magicAPIService
.
registerAllDataSource
();
...
...
magic-api-spring-boot-starter/src/main/java/org/ssssssss/magicapi/spring/boot/starter/MagicSwaggerConfiguration.java
浏览文件 @
a6da9a34
...
...
@@ -51,7 +51,8 @@ public class MagicSwaggerConfiguration {
@Primary
public
SwaggerResourcesProvider
magicSwaggerResourcesProvider
(
MappingHandlerMapping
handlerMapping
,
GroupServiceProvider
groupServiceProvider
,
ServletContext
servletContext
)
throws
NoSuchMethodException
{
SwaggerConfig
config
=
properties
.
getSwaggerConfig
();
RequestMappingInfo
requestMappingInfo
=
RequestMappingInfo
.
paths
(
config
.
getLocation
()).
build
();
Mapping
mapping
=
Mapping
.
create
(
requestMappingHandlerMapping
);
RequestMappingInfo
requestMappingInfo
=
mapping
.
paths
(
config
.
getLocation
()).
build
();
// 构建文档信息
SwaggerProvider
swaggerProvider
=
new
SwaggerProvider
();
...
...
@@ -64,7 +65,7 @@ public class MagicSwaggerConfiguration {
// 注册swagger.json
Mapping
.
create
(
requestMappingHandlerMapping
)
.
register
(
requestMappingInfo
,
swaggerProvider
,
SwaggerProvider
.
class
.
getDeclaredMethod
(
"swaggerJson"
));
mapping
.
register
(
requestMappingInfo
,
swaggerProvider
,
SwaggerProvider
.
class
.
getDeclaredMethod
(
"swaggerJson"
));
return
()
->
{
List
<
SwaggerResource
>
resources
=
new
ArrayList
<>();
...
...
magic-api/src/main/java/org/ssssssss/magicapi/adapter/resource/RedisResource.java
浏览文件 @
a6da9a34
...
...
@@ -8,7 +8,6 @@ import org.springframework.data.redis.core.ScanOptions;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.ssssssss.magicapi.adapter.Resource
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -98,7 +97,7 @@ public class RedisResource extends KeyValueResource {
@Override
protected
Set
<
String
>
keys
()
{
Set
<
String
>
keys
=
this
.
redisTemplate
.
execute
((
RedisCallback
<
Set
<
String
>>)
connection
->
{
ScanOptions
options
=
new
ScanOptions
.
ScanOptionsBuilder
()
ScanOptions
options
=
ScanOptions
.
scanOptions
()
.
count
(
Long
.
MAX_VALUE
)
.
match
((
isDirectory
()
?
this
.
path
:
(
this
.
path
+
separator
))
+
"*"
)
.
build
();
...
...
@@ -107,7 +106,7 @@ public class RedisResource extends KeyValueResource {
while
(
cursor
.
hasNext
())
{
returnKeys
.
add
(
new
String
(
cursor
.
next
()));
}
}
catch
(
IO
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"扫描key出错"
,
e
);
}
return
returnKeys
;
...
...
magic-api/src/main/java/org/ssssssss/magicapi/config/MappingHandlerMapping.java
浏览文件 @
a6da9a34
...
...
@@ -442,7 +442,7 @@ public class MappingHandlerMapping {
RequestMapping
requestMapping
=
method
.
getAnnotation
(
RequestMapping
.
class
);
if
(
requestMapping
!=
null
)
{
String
[]
paths
=
Stream
.
of
(
requestMapping
.
value
()).
map
(
value
->
base
+
value
).
toArray
(
String
[]::
new
);
mappingHelper
.
register
(
RequestMappingInfo
.
paths
(
paths
).
build
(),
target
,
method
);
mappingHelper
.
register
(
mappingHelper
.
paths
(
paths
).
build
(),
target
,
method
);
}
}
}
...
...
@@ -479,14 +479,14 @@ public class MappingHandlerMapping {
* 根据接口信息构建 RequestMappingInfo
*/
private
RequestMappingInfo
getRequestMapping
(
ApiInfo
info
)
{
return
RequestMappingInfo
.
paths
(
getRequestPath
(
info
.
getGroupId
(),
info
.
getPath
())).
methods
(
RequestMethod
.
valueOf
(
info
.
getMethod
().
toUpperCase
())).
build
();
return
mappingHelper
.
paths
(
getRequestPath
(
info
.
getGroupId
(),
info
.
getPath
())).
methods
(
RequestMethod
.
valueOf
(
info
.
getMethod
().
toUpperCase
())).
build
();
}
/**
* 根据接口信息构建 RequestMappingInfo
*/
private
RequestMappingInfo
getRequestMapping
(
String
method
,
String
path
)
{
return
RequestMappingInfo
.
paths
(
path
).
methods
(
RequestMethod
.
valueOf
(
method
.
toUpperCase
())).
build
();
return
mappingHelper
.
paths
(
path
).
methods
(
RequestMethod
.
valueOf
(
method
.
toUpperCase
())).
build
();
}
static
class
MappingNode
{
...
...
magic-api/src/main/java/org/ssssssss/magicapi/utils/Mapping.java
浏览文件 @
a6da9a34
...
...
@@ -3,7 +3,7 @@ package org.ssssssss.magicapi.utils;
import
org.springframework.web.method.HandlerMethod
;
import
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping
;
import
org.springframework.web.servlet.mvc.method.RequestMappingInfo
;
import
org.springframework.web.servlet.mvc.method.
RequestMappingInfo
HandlerMapping
;
import
org.springframework.web.servlet.mvc.method.
annotation.RequestMapping
HandlerMapping
;
import
java.lang.reflect.Method
;
import
java.util.Map
;
...
...
@@ -17,12 +17,27 @@ public class Mapping {
private
final
AbstractHandlerMethodMapping
<
RequestMappingInfo
>
methodMapping
;
private
Mapping
(
AbstractHandlerMethodMapping
<
RequestMappingInfo
>
methodMapping
)
{
private
RequestMappingInfo
.
BuilderConfiguration
config
;
private
Mapping
(
AbstractHandlerMethodMapping
<
RequestMappingInfo
>
methodMapping
,
RequestMappingInfo
.
BuilderConfiguration
config
)
{
this
.
methodMapping
=
methodMapping
;
this
.
config
=
config
;
}
public
static
Mapping
create
(
RequestMappingHandlerMapping
mapping
)
{
RequestMappingInfo
.
BuilderConfiguration
config
=
new
RequestMappingInfo
.
BuilderConfiguration
();
config
.
setTrailingSlashMatch
(
mapping
.
useTrailingSlashMatch
());
config
.
setContentNegotiationManager
(
mapping
.
getContentNegotiationManager
());
if
(
mapping
.
getPatternParser
()
!=
null
)
{
config
.
setPatternParser
(
mapping
.
getPatternParser
());
}
else
{
config
.
setPathMatcher
(
mapping
.
getPathMatcher
());
}
return
new
Mapping
(
mapping
,
config
);
}
public
static
Mapping
create
(
RequestMappingInfoHandlerMapping
mapping
)
{
return
new
Mapping
(
mappin
g
);
public
RequestMappingInfo
.
Builder
paths
(
String
...
paths
)
{
return
RequestMappingInfo
.
paths
(
paths
).
options
(
this
.
confi
g
);
}
public
Mapping
register
(
RequestMappingInfo
requestMappingInfo
,
Object
handler
,
Method
method
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录