Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibiz-boot-starters
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibiz-boot-starters
提交
613fe641
提交
613fe641
编写于
7月 16, 2022
作者:
ibiz4j
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
接口实体适配
上级
b3b08247
变更
5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
142 行增加
和
45 行删除
+142
-45
BaseData.java
...net/ibizsys/central/plugin/boot/core/domain/BaseData.java
+11
-9
BootServiceImpl.java
...sys/central/plugin/boot/core/runtime/BootServiceImpl.java
+3
-23
IBaseService.java
...bizsys/central/plugin/boot/core/service/IBaseService.java
+4
-0
IServiceApiService.java
.../central/plugin/boot/core/service/IServiceApiService.java
+86
-13
BaseServiceImpl.java
...entral/plugin/boot/core/service/impl/BaseServiceImpl.java
+38
-0
未找到文件。
ibiz-boot-starter/src/main/java/net/ibizsys/central/plugin/boot/core/domain/BaseData.java
浏览文件 @
613fe641
...
...
@@ -131,6 +131,7 @@ public class BaseData implements IEntityDTO {
}
else
{
focusNull
.
remove
(
field
);
paramMap
.
remove
(
field
+
"dirtyflag"
);
}
}
...
...
@@ -275,14 +276,14 @@ public class BaseData implements IEntityDTO {
}
public
boolean
containsKey
(
String
strName
)
{
if
(
getFocusNull
()
.
contains
(
strName
))
if
(
focusNull
.
contains
(
strName
))
return
true
;
String
fieldRealName
=
FieldCache
.
getFieldRealName
(
this
.
getClass
(),
strName
);
if
(!
StringUtils
.
isEmpty
(
field
RealName
))
{
if
(
getFocusNull
().
contains
(
strName
))
FieldCache
.
FieldItem
fieldItem
=
FieldCache
.
getField
(
this
.
getClass
(),
strName
);
if
(!
StringUtils
.
isEmpty
(
field
Item
.
getCodeName
()
))
{
if
(
focusNull
.
contains
(
fieldItem
.
getJsonName
()
))
return
true
;
return
getMap
().
get
(
field
RealName
)!=
null
;
return
getMap
().
get
(
field
Item
.
getCodeName
()
)!=
null
;
}
else
{
return
this
.
paramMap
.
containsKey
(
strName
);
...
...
@@ -404,10 +405,11 @@ public class BaseData implements IEntityDTO {
}
public
void
resetObject
(
String
strName
)
{
String
fieldRealName
=
FieldCache
.
getFieldRealName
(
this
.
getClass
(),
strName
);
if
(!
StringUtils
.
isEmpty
(
fieldRealName
))
{
getMap
().
put
(
fieldRealName
,
null
);
focusNull
.
remove
(
fieldRealName
);
FieldCache
.
FieldItem
fieldItem
=
FieldCache
.
getField
(
this
.
getClass
(),
strName
);
if
(
fieldItem
!=
null
&&(!
StringUtils
.
isEmpty
(
fieldItem
.
getCodeName
())))
{
getMap
().
put
(
fieldItem
.
getCodeName
(),
null
);
focusNull
.
remove
(
fieldItem
.
getJsonName
());
paramMap
.
remove
(
fieldItem
.
getJsonName
()+
"dirtyflag"
);
}
else
{
this
.
paramMap
.
remove
(
strName
);
...
...
ibiz-boot-starter/src/main/java/net/ibizsys/central/plugin/boot/core/runtime/BootServiceImpl.java
浏览文件 @
613fe641
...
...
@@ -28,14 +28,12 @@ import java.util.Map;
public
class
BootServiceImpl
<
T
extends
BaseData
,
F
extends
BaseFilter
>
extends
DEServiceBase
implements
IBootService
<
T
,
F
>
{
private
Class
<
T
>
tClass
;
private
Class
<
F
>
fClass
;
@Override
public
T
createEntityDTO
(
IPSDEMethodDTO
iPSDEMethodDTO
)
{
if
(
iPSDEMethodDTO
!=
null
&&
iPSDEMethodDTO
.
getName
()!=
null
&&
iPSDEMethodDTO
.
getName
().
endsWith
(
"DTO"
))
{
try
{
T
t
=
(
T
)
t
Class
.
newInstance
();
T
t
=
(
T
)
t
his
.
getBaseService
().
getTClass
()
.
newInstance
();
return
t
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -47,7 +45,7 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D
@Override
public
F
createSearchContextDTO
(
IPSDEMethodDTO
iPSDEMethodDTO
)
{
try
{
F
f
=
(
F
)
fClass
.
newInstance
();
F
f
=
(
F
)
this
.
getBaseService
().
getFClass
()
.
newInstance
();
return
f
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -97,25 +95,7 @@ public class BootServiceImpl<T extends BaseData, F extends BaseFilter> extends D
return
;
this
.
baseService
=
baseService
;
this
.
setDataEntityId
(
baseService
.
getDataEntityId
());
Class
serviceClass
=
baseService
.
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
))
{
serviceClass
=
interfaceClass
;
break
;
}
}
}
serviceClass
=
serviceClass
.
getSuperclass
();
}
if
(!
ObjectUtils
.
isEmpty
(
serviceClass
.
getGenericInterfaces
()))
{
ParameterizedType
ptype
=
(
ParameterizedType
)
serviceClass
.
getGenericInterfaces
()[
0
];
tClass
=
(
Class
)
ptype
.
getActualTypeArguments
()[
0
];
fClass
=
(
Class
)
ptype
.
getActualTypeArguments
()[
1
];
}
}
public
IBaseService
getBaseService
(){
return
baseService
;
...
...
ibiz-boot-starter/src/main/java/net/ibizsys/central/plugin/boot/core/service/IBaseService.java
浏览文件 @
613fe641
...
...
@@ -36,6 +36,10 @@ public interface IBaseService<T extends BaseData, F extends BaseFilter> {
Method
getServiceMethod
(
String
name
,
Class
clazz
);
Class
<
T
>
getTClass
();
Class
<
F
>
getFClass
();
default
IDataEntityRuntimeContext
getDataEntityRuntimeContext
()
{
return
getRuntimeService
().
getDataEntityRuntimeContext
();
}
...
...
ibiz-boot-starter/src/main/java/net/ibizsys/central/plugin/boot/core/service/IServiceApiService.java
浏览文件 @
613fe641
package
net
.
ibizsys
.
central
.
plugin
.
boot
.
core
.
service
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.util.TypeUtils
;
import
net.ibizsys.central.dataentity.IDataEntityRuntime
;
import
net.ibizsys.central.dataentity.IDataEntityRuntimeContext
;
import
net.ibizsys.central.plugin.boot.core.domain.BaseData
;
...
...
@@ -7,9 +11,15 @@ import net.ibizsys.central.plugin.boot.core.filter.BaseFilter;
import
net.ibizsys.central.plugin.boot.core.helper.StringAdvUtils
;
import
net.ibizsys.central.plugin.boot.core.runtime.IBootService
;
import
net.ibizsys.central.plugin.boot.core.runtime.IBootSystemRuntime
;
import
net.ibizsys.central.service.client.IWebClientRep
;
import
net.ibizsys.central.util.IEntityDTO
;
import
net.ibizsys.central.util.PageRequest
;
import
net.ibizsys.model.dataentity.action.IPSDEAction
;
import
net.ibizsys.model.dataentity.ds.IPSDEDataSet
;
import
net.ibizsys.runtime.util.DataTypeUtils
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.util.Assert
;
import
java.io.Serializable
;
import
java.lang.reflect.InvocationTargetException
;
...
...
@@ -20,48 +30,111 @@ import java.util.List;
public
interface
IServiceApiService
<
T
extends
BaseData
,
F
extends
BaseFilter
>
extends
IBaseService
<
T
,
F
>{
default
void
beforeAction
(
String
strActionName
,
Object
arg
)
throws
Throwable
{
if
(
arg
.
getClass
().
isAssignableFrom
(
getTClass
()))
{
T
data
=((
T
)
arg
);
data
.
getFocusNull
().
forEach
(
item
->{
data
.
setObject
(
item
+
"dirtyflag"
,
1
);
});
data
.
setObject
(
"dirtyflagenable"
,
1
);
}
try
{
Method
beforeMethod
=
getServiceMethod
(
"before"
+
StringAdvUtils
.
pascalcase
(
strActionName
),
arg
.
getClass
());
if
(
beforeMethod
!=
null
)
beforeMethod
.
invoke
(
this
,
arg
);
}
catch
(
InvocationTargetException
ex
){
throw
ex
.
getTargetException
();
}
}
default
Object
onRealAction
(
String
strActionName
,
Object
arg
)
throws
Throwable
{
return
this
.
getDataEntityRuntimeContext
().
executeActionReal
(
strActionName
,
null
,
new
Object
[]{
arg
},
null
);
return
onRealAction
(
strActionName
,
arg
,
getTClass
()
);
}
default
Object
onRealFetch
(
String
dsName
,
F
arg
)
throws
Throwable
{
return
this
.
getDataEntityRuntimeContext
().
fetchDataSetReal
(
"DEFAULT"
,
arg
.
getDataSet
(),
new
Object
[]{
arg
},
null
);
default
<
K
>
List
<
K
>
onRealActionList
(
String
strActionName
,
Object
arg
,
Class
<
K
>
clazz
)
throws
Throwable
{
Object
obj
=
this
.
getDataEntityRuntimeContext
().
executeActionReal
(
strActionName
,
null
,
new
Object
[]{
arg
},
null
);
if
(
obj
instanceof
IWebClientRep
)
{
String
body
=((
IWebClientRep
<
String
>)
obj
).
getBody
();
Assert
.
hasText
(
body
,
String
.
format
(
"[{}]接口服务返回为空"
,
strActionName
));
return
JSON
.
parseArray
(
body
,
clazz
);
}
return
(
List
<
K
>)
obj
;
}
default
<
K
>
K
onRealAction
(
String
strActionName
,
Object
arg
,
Class
<
K
>
clazz
)
throws
Throwable
{
Object
obj
=
this
.
getDataEntityRuntimeContext
().
executeActionReal
(
strActionName
,
null
,
new
Object
[]{
arg
},
null
);
if
(
obj
instanceof
IWebClientRep
)
{
String
body
=((
IWebClientRep
<
String
>)
obj
).
getBody
();
Assert
.
hasText
(
body
,
String
.
format
(
"[{}]接口服务返回为空"
,
strActionName
));
K
ret
=
JSON
.
parseObject
(
body
,
clazz
);
if
(
arg
.
getClass
().
isAssignableFrom
(
getTClass
())&&
clazz
.
isAssignableFrom
(
getTClass
()))
((
T
)
arg
).
reload
(((
T
)
ret
).
any
(),
true
);
}
return
(
K
)
obj
;
}
default
Object
onRealFetch
(
String
dsName
,
F
arg
)
throws
Throwable
{
return
onRealFetchPage
(
dsName
,
arg
);
}
default
<
K
extends
Serializable
>
T
onGet
(
K
key
)
throws
Throwable
{
return
(
T
)
onRealAction
(
"Get"
,
key
);
default
List
<
T
>
onRealSearch
(
String
dsName
,
F
arg
)
throws
Throwable
{
Object
obj
=
this
.
getRuntimeService
().
getDataEntityRuntime
().
selectDataQuery
(
dsName
,
arg
);
if
(
obj
instanceof
IWebClientRep
)
{
IWebClientRep
<
String
>
rep
=(
IWebClientRep
)
obj
;
Assert
.
hasText
(
rep
.
getBody
(),
String
.
format
(
"[{}]查询服务返回为空"
,
dsName
));
JSON
json
=(
JSON
)
JSON
.
parse
(
rep
.
getBody
());
if
(
json
instanceof
JSONArray
)
{
return
JSON
.
parseArray
(
rep
.
getBody
(),
getTClass
());
}
else
if
(
json
instanceof
JSONObject
){
if
(((
JSONObject
)
json
).
containsKey
(
"content"
))
return
JSON
.
parseArray
(
JSON
.
toJSONString
(((
JSONObject
)
json
).
getJSONArray
(
"content"
)),
getTClass
());
}
}
return
(
List
)
obj
;
}
default
Page
<
T
>
onRealFetchPage
(
String
dsName
,
F
arg
)
throws
Throwable
{
Object
obj
=
this
.
getDataEntityRuntimeContext
().
fetchDataSetReal
(
"DEFAULT"
,
arg
.
getDataSet
(),
new
Object
[]{
arg
},
null
);
if
(
obj
instanceof
IWebClientRep
)
{
IWebClientRep
<
String
>
rep
=(
IWebClientRep
)
obj
;
Assert
.
hasText
(
rep
.
getBody
(),
String
.
format
(
"[{}]查询服务返回为空"
,
dsName
));
JSON
json
=(
JSON
)
JSON
.
parse
(
rep
.
getBody
());
if
(
json
instanceof
JSONArray
)
{
Long
nTotal
=
DataTypeUtils
.
getLongValue
(
rep
.
getHeader
(
"x-total"
),
0L
);
return
new
PageImpl
(
JSON
.
parseArray
(
rep
.
getBody
(),
getTClass
()),
arg
.
getPageable
(),
nTotal
);
}
else
if
(
json
instanceof
JSONObject
){
Long
nTotal
=
DataTypeUtils
.
getLongValue
(((
JSONObject
)
json
).
getLongValue
(
"totalElements"
),
0L
);
return
new
PageImpl
(
JSON
.
parseArray
(
JSON
.
toJSONString
(((
JSONObject
)
json
).
getJSONArray
(
"content"
)),
getTClass
()),
arg
.
getPageable
(),
nTotal
);
}
}
return
(
Page
)
obj
;
}
default
T
onGetDraft
(
T
dto
)
throws
Throwable
{
return
(
T
)
onRealAction
(
"GetDraft"
,
dto
);
}
default
Integer
onCheckKey
(
T
dto
)
throws
Throwable
{
return
(
Integer
)
onRealAction
(
"CheckKey"
,
dto
);
return
onRealAction
(
"CheckKey"
,
dto
,
Integer
.
class
);
}
default
Page
<
T
>
onFetchDefault
(
F
dto
)
throws
Throwable
{
return
(
Page
)
onRealFetch
(
"DEFAULT"
,
dto
);
return
onRealFetchPage
(
"DEFAULT"
,
dto
);
}
default
List
<
T
>
selectDefault
(
F
dto
)
throws
Throwable
{
return
(
List
)
this
.
getRuntimeService
().
getDataEntityRuntime
().
selectDataQuery
(
"DEFAULT"
,
dto
);
return
onRealSearch
(
"DEFAULT"
,
dto
);
}
default
List
<
T
>
selectSimple
(
F
dto
)
throws
Throwable
{
return
(
List
)
this
.
getRuntimeService
().
getDataEntityRuntime
().
selectDataQuery
(
"SIMPLE"
,
dto
);
return
onRealSearch
(
"SIMPLE"
,
dto
);
}
default
List
<
T
>
selectView
(
F
dto
)
throws
Throwable
{
return
(
List
)
this
.
getRuntimeService
().
getDataEntityRuntime
().
selectDataQuery
(
"VIEW"
,
dto
);
return
onRealSearch
(
"VIEW"
,
dto
);
}
}
ibiz-boot-starter/src/main/java/net/ibizsys/central/plugin/boot/core/service/impl/BaseServiceImpl.java
浏览文件 @
613fe641
...
...
@@ -5,13 +5,19 @@ import net.ibizsys.central.plugin.boot.core.filter.BaseFilter;
import
net.ibizsys.central.plugin.boot.core.runtime.BootServiceImpl
;
import
net.ibizsys.central.plugin.boot.core.runtime.IBootService
;
import
net.ibizsys.central.plugin.boot.core.service.IBaseService
;
import
net.ibizsys.central.plugin.boot.core.service.IMPService
;
import
net.ibizsys.central.plugin.boot.core.service.IServiceApiService
;
import
org.apache.commons.lang3.ObjectUtils
;
import
javax.annotation.PostConstruct
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.ParameterizedType
;
import
java.util.HashMap
;
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
(){
...
...
@@ -24,9 +30,41 @@ public abstract class BaseServiceImpl<T extends BaseData, F extends BaseFilter>
@PostConstruct
private
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
;
break
;
}
}
}
serviceClass
=
serviceClass
.
getSuperclass
();
}
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
);
}
private
Class
<
T
>
tClass
;
private
Class
<
F
>
fClass
;
public
Class
<
T
>
getTClass
()
{
return
tClass
;
}
public
Class
<
F
>
getFClass
()
{
return
fClass
;
}
private
Object
lockMethods
=
new
Object
();
private
Map
<
String
,
Method
>
serviceMethods
=
new
HashMap
<>();
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录