Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibiz-boot-starters
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibiz-boot-starters
提交
d8e5045b
提交
d8e5045b
编写于
9月 02, 2024
作者:
xignzi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
兼容service.getById()方法返回dto对象为dto的代理对象,然后调用实体行为异常
兼容批量行为处理
上级
571d4ed0
变更
1
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
42 行增加
和
23 行删除
+42
-23
BaseServiceImpl.java
...entral/plugin/boot/core/service/impl/BaseServiceImpl.java
+42
-23
未找到文件。
ibiz-boot-starter/src/main/java/net/ibizsys/central/plugin/boot/core/service/impl/BaseServiceImpl.java
浏览文件 @
d8e5045b
...
...
@@ -13,14 +13,16 @@ import javax.annotation.PostConstruct;
import
java.lang.reflect.Method
;
import
java.lang.reflect.ParameterizedType
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
abstract
class
BaseServiceImpl
<
T
extends
BaseData
,
F
extends
BaseFilter
>
implements
IBaseService
<
T
,
F
>
{
private
IBootService
runtimeService
;
@Override
public
IBootService
getRuntimeService
(){
public
IBootService
getRuntimeService
()
{
return
runtimeService
;
}
...
...
@@ -30,27 +32,27 @@ public abstract class BaseServiceImpl<T extends BaseData, F extends BaseFilter>
@PostConstruct
protected
void
postConstruct
()
throws
Exception
{
Class
serviceClass
=
this
.
getClass
();
while
(
serviceClass
!=
null
)
{
if
(!
ObjectUtils
.
isEmpty
(
serviceClass
.
getInterfaces
()))
{
Class
interfaceClass
=
serviceClass
.
getInterfaces
()[
0
];
if
(!
ObjectUtils
.
isEmpty
(
interfaceClass
.
getInterfaces
()))
{
if
(
interfaceClass
.
getInterfaces
()[
0
].
isAssignableFrom
(
IBaseService
.
class
)
||
interfaceClass
.
getInterfaces
()[
0
].
isAssignableFrom
(
IMPService
.
class
)
||
interfaceClass
.
getInterfaces
()[
0
].
isAssignableFrom
(
IServiceApiService
.
class
))
{
serviceClass
=
interfaceClass
;
Class
serviceClass
=
this
.
getClass
();
while
(
serviceClass
!=
null
)
{
if
(!
ObjectUtils
.
isEmpty
(
serviceClass
.
getInterfaces
()))
{
Class
interfaceClass
=
serviceClass
.
getInterfaces
()[
0
];
if
(!
ObjectUtils
.
isEmpty
(
interfaceClass
.
getInterfaces
()))
{
if
(
interfaceClass
.
getInterfaces
()[
0
].
isAssignableFrom
(
IBaseService
.
class
)
||
interfaceClass
.
getInterfaces
()[
0
].
isAssignableFrom
(
IMPService
.
class
)
||
interfaceClass
.
getInterfaces
()[
0
].
isAssignableFrom
(
IServiceApiService
.
class
))
{
serviceClass
=
interfaceClass
;
break
;
}
}
}
serviceClass
=
serviceClass
.
getSuperclass
();
}
if
(!
ObjectUtils
.
isEmpty
(
serviceClass
.
getGenericInterfaces
()))
{
if
(!
ObjectUtils
.
isEmpty
(
serviceClass
.
getGenericInterfaces
()))
{
ParameterizedType
ptype
=
(
ParameterizedType
)
serviceClass
.
getGenericInterfaces
()[
0
];
tClass
=
(
Class
)
ptype
.
getActualTypeArguments
()[
0
];
fClass
=
(
Class
)
ptype
.
getActualTypeArguments
()[
1
];
}
runtimeService
=
new
BootServiceImpl
<
T
,
F
>(
this
);
runtimeService
=
new
BootServiceImpl
<
T
,
F
>(
this
);
}
...
...
@@ -67,24 +69,41 @@ public abstract class BaseServiceImpl<T extends BaseData, F extends BaseFilter>
private
Object
lockMethods
=
new
Object
();
private
Map
<
String
,
Method
>
serviceMethods
=
new
HashMap
<>();
private
Map
<
String
,
Method
>
serviceMethods
=
new
HashMap
<>();
public
Method
getServiceMethod
(
String
name
,
Class
clazz
)
{
public
Method
getServiceMethod
(
String
name
,
Class
clazz
)
{
Method
method
=
null
;
synchronized
(
lockMethods
)
{
String
tag
=
name
;
if
(
clazz
.
isArray
())
tag
=
tag
+
"List"
;
if
(
serviceMethods
.
containsKey
(
tag
))
synchronized
(
lockMethods
)
{
String
tag
=
name
;
if
(
clazz
.
isArray
())
tag
=
tag
+
"List"
;
if
(
serviceMethods
.
containsKey
(
tag
))
return
serviceMethods
.
get
(
tag
);
try
{
method
=
this
.
getClass
().
getMethod
(
name
,
clazz
);
method
=
this
.
getClass
().
getMethod
(
name
,
clazz
);
}
catch
(
NoSuchMethodException
e
)
{
if
(
clazz
.
getSuperclass
()
!=
null
)
{
// method = getServiceMethod(name, clazz.getSuperclass());
try
{
//只做一次父 防止mybatis.get返回的是代理dto
method
=
this
.
getClass
().
getMethod
(
name
,
clazz
.
getSuperclass
());
}
catch
(
NoSuchMethodException
e2
)
{
}
}
//批量 List对象
if
(
List
.
class
.
isAssignableFrom
(
clazz
)){
try
{
method
=
this
.
getClass
().
getMethod
(
name
,
List
.
class
);
}
catch
(
NoSuchMethodException
e2
)
{
}
}
}
serviceMethods
.
put
(
tag
,
method
);
serviceMethods
.
put
(
tag
,
method
);
}
return
method
;
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录