Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzwf
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzwf
提交
f56f42cd
提交
f56f42cd
编写于
5月 08, 2020
作者:
ibizdev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ibizdev提交
上级
c7abe26b
变更
2
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
167 行增加
和
219 行删除
+167
-219
DEFieldDefaultValueAspect.java
...ava/cn/ibizlab/util/aspect/DEFieldDefaultValueAspect.java
+118
-218
DEFieldCacheMap.java
...src/main/java/cn/ibizlab/util/helper/DEFieldCacheMap.java
+49
-1
未找到文件。
ibzwf-util/src/main/java/cn/ibizlab/util/aspect/DEFieldDefaultValueAspect.java
浏览文件 @
f56f42cd
package
cn
.
ibizlab
.
util
.
aspect
;
import
cn.ibizlab.util.annotation.DEField
;
import
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
cn.ibizlab.util.enums.DEPredefinedFieldType
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
...
...
@@ -8,18 +9,13 @@ import cn.ibizlab.util.security.AuthenticationUser;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.springframework.cglib.beans.BeanMap
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.AlternativeJdkIdGenerator
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.sql.Timestamp
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -36,80 +32,41 @@ public class DEFieldDefaultValueAspect
* @param point
* @throws Exception
*/
@Before
(
value
=
"execution(* c
n.ibizlab
.core.*.service.*.create(..))"
)
@Before
(
value
=
"execution(* c
om.cntmtech.support
.core.*.service.*.create(..))"
)
public
void
BeforeCreate
(
JoinPoint
point
)
throws
Exception
{
fillDEFieldDefaultValue
(
point
);
}
@Before
(
value
=
"execution(* com.cntmtech.support.core.*.service.*.createBatch(..))"
)
public
void
BeforeCreateBatch
(
JoinPoint
point
)
throws
Exception
{
fillDEFieldDefaultValue
(
point
);
}
/**
* 更新数据切入点
* @param point
* @throws Exception
*/
@Before
(
value
=
"execution(* c
n.ibizlab
.core.*.service.*.update(..))"
)
@Before
(
value
=
"execution(* c
om.cntmtech.support
.core.*.service.*.update(..))"
)
public
void
BeforeUpdate
(
JoinPoint
point
)
throws
Exception
{
fillDEFieldDefaultValue
(
point
);
}
@Before
(
value
=
"execution(* com.cntmtech.support.core.*.service.*.updateBatch(..))"
)
public
void
BeforeUpdateBatch
(
JoinPoint
point
)
throws
Exception
{
fillDEFieldDefaultValue
(
point
);
}
/**
* 保存数据切入点
* @param point
* @throws Exception
*/
@Before
(
value
=
"execution(* c
n.ibizlab
.core.*.service.*.save(..))"
)
@Before
(
value
=
"execution(* c
om.cntmtech.support
.core.*.service.*.save(..))"
)
public
void
BeforeSave
(
JoinPoint
point
)
throws
Exception
{
checkAction
(
point
);
}
/**
* 判断当前是否为新建操作,若为新建,则填充属性默认值
* @param joinPoint
* @throws Exception
*/
private
void
checkAction
(
JoinPoint
joinPoint
)
throws
Exception
{
Object
[]
args
=
joinPoint
.
getArgs
();
if
(
args
.
length
>
0
)
{
Object
obj
=
args
[
0
];
String
className
=
obj
.
getClass
().
getName
();
//获取当前do对象中的属性
DEFieldCacheMap
.
getFieldMap
(
className
);
//从属性列表中过滤出主键属性
Field
keyPSDEField
=
this
.
getKeyPSDEField
(
className
);
if
(
ObjectUtils
.
isEmpty
(
keyPSDEField
))
return
;
String
filename
=
keyPSDEField
.
getName
();
PropertyDescriptor
field
=
new
PropertyDescriptor
(
filename
,
obj
.
getClass
());
Method
fieldGetMethod
=
field
.
getReadMethod
();
//获取主键值
Object
fieldValue
=
fieldGetMethod
.
invoke
(
obj
);
//实体数据主键为空,则为新建操作,填充属性默认值
if
(
ObjectUtils
.
isEmpty
(
fieldValue
)){
fillDEFieldDefaultValue
(
joinPoint
);
}
}
}
/**
* 获取主键属性
* @param className 实体类名
* @return 主键属性
*/
private
Field
getKeyPSDEField
(
String
className
){
Field
keyField
=
null
;
List
<
Field
>
fields
=
DEFieldCacheMap
.
getFields
(
className
);
for
(
Field
field:
fields
){
DEField
deField
=
field
.
getAnnotation
(
DEField
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
deField
)
&&
deField
.
isKeyField
())
{
return
field
;
}
fillDEFieldDefaultValue
(
point
);
}
return
keyField
;
@Before
(
value
=
"execution(* com.cntmtech.support.core.*.service.*.saveBatch(..))"
)
public
void
BeforeSaveBatch
(
JoinPoint
point
)
throws
Exception
{
fillDEFieldDefaultValue
(
point
);
}
/**
...
...
@@ -119,53 +76,56 @@ public class DEFieldDefaultValueAspect
* @throws Exception
*/
public
Object
fillDEFieldDefaultValue
(
JoinPoint
joinPoint
)
throws
Exception
{
Object
[]
args
=
joinPoint
.
getArgs
();
if
(
args
.
length
>
0
)
{
Object
obj
=
args
[
0
];
String
className
=
obj
.
getClass
().
getName
();
//获取当前po对象中的属性
DEFieldCacheMap
.
getFieldMap
(
className
);
//从属性列表中过滤出预置属性
Map
<
Field
,
DEField
>
deFields
=
this
.
SearchDEField
(
className
);
//填充预置属性
fillDEField
(
obj
,
deFields
,
joinPoint
);
String
actionName
=
joinPoint
.
getSignature
().
getName
();
if
(
obj
instanceof
EntityBase
)
{
Map
<
String
,
DEField
>
deFields
=
DEFieldCacheMap
.
getDEFields
(
obj
.
getClass
());
AuthenticationUser
curUser
=
AuthenticationUser
.
getAuthenticationUser
();
String
keyField
=
DEFieldCacheMap
.
getDEKeyField
(
obj
.
getClass
());
if
(
StringUtils
.
isEmpty
(
keyField
))
return
true
;
}
fillDEField
((
EntityBase
)
obj
,
deFields
,
actionName
,
curUser
,
keyField
);
}
else
if
(
obj
instanceof
List
)
{
Map
<
String
,
DEField
>
deFields
=
null
;
AuthenticationUser
curUser
=
null
;
String
keyField
=
""
;
for
(
Object
item:
(
List
)
obj
)
{
if
(
item
instanceof
EntityBase
)
{
if
(
deFields
==
null
)
{
deFields
=
DEFieldCacheMap
.
getDEFields
(
obj
.
getClass
());
curUser
=
AuthenticationUser
.
getAuthenticationUser
();
keyField
=
DEFieldCacheMap
.
getDEKeyField
(
obj
.
getClass
());
if
(
StringUtils
.
isEmpty
(
keyField
))
return
true
;
}
/**
*获取含有@DEField注解的实体属性
* @param className do对象类名
* @return
*/
private
Map
<
Field
,
DEField
>
SearchDEField
(
String
className
){
List
<
Field
>
fields
=
DEFieldCacheMap
.
getFields
(
className
);
Map
<
Field
,
DEField
>
deFieldMap
=
new
HashMap
<>();
for
(
Field
field:
fields
){
DEField
deField
=
field
.
getAnnotation
(
DEField
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
deField
))
{
deFieldMap
.
put
(
field
,
deField
);
fillDEField
((
EntityBase
)
item
,
deFields
,
actionName
,
curUser
,
keyField
);
}
}
}
return
deFieldMap
;
}
return
true
;
}
/**
* 填充系统预置属性
* @param et 当前实体对象
*/
private
void
fillDEField
(
Object
et
,
Map
<
Field
,
DEField
>
deFields
,
JoinPoint
joinPoint
)
throws
Exception
{
private
void
fillDEField
(
EntityBase
et
,
Map
<
String
,
DEField
>
deFields
,
String
actionName
,
AuthenticationUser
curUser
,
String
keyField
)
throws
Exception
{
if
(
deFields
.
size
()==
0
)
return
;
for
(
Map
.
Entry
<
Field
,
DEField
>
entry
:
deFields
.
entrySet
())
{
if
(
actionName
.
toLowerCase
().
startsWith
(
"save"
))
{
if
(
ObjectUtils
.
isEmpty
(
et
.
get
(
keyField
)))
actionName
=
"create"
;
}
Field
deField
=
entry
.
getKey
();
String
fi
leName
=
deField
.
getName
();
for
(
Map
.
Entry
<
String
,
DEField
>
entry
:
deFields
.
entrySet
())
{
String
fi
eldname
=
entry
.
getKey
();
//获取注解
DEField
fieldAnnotation
=
entry
.
getValue
();
//获取默认值类型
...
...
@@ -176,43 +136,35 @@ public class DEFieldDefaultValueAspect
DEPredefinedFieldType
predefinedFieldType
=
fieldAnnotation
.
preType
();
//填充系统默认值
if
(
deFieldType
!=
DEFieldDefaultValueType
.
NONE
||
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
){
fillFieldDefaultValue
(
fi
leName
,
deFieldType
,
deFieldDefaultValue
,
et
,
fieldAnnotation
)
;
if
(
actionName
.
toLowerCase
().
startsWith
(
"create"
)
&&
(
deFieldType
!=
DEFieldDefaultValueType
.
NONE
||
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
)
){
fillFieldDefaultValue
(
fi
eldname
,
deFieldType
,
deFieldDefaultValue
,
et
,
curUser
)
;
}
//填充系统预置属性
if
(
predefinedFieldType
!=
DEPredefinedFieldType
.
NONE
){
fillPreFieldValue
(
fi
leName
,
predefinedFieldType
,
et
,
joinPoint
,
fieldAnnotation
);
fillPreFieldValue
(
fi
eldname
,
predefinedFieldType
,
et
,
actionName
,
fieldAnnotation
.
logicval
(),
curUser
);
}
}
}
/**
* 填充属性默认值
* @param fi
leN
ame 实体属性名
* @param fi
eldn
ame 实体属性名
* @param deFieldType 默认值类型
* @param deFieldDefaultValue 默认值
* @param et 当前实体对象
* @throws Exception
*/
private
void
fillFieldDefaultValue
(
String
fileName
,
DEFieldDefaultValueType
deFieldType
,
String
deFieldDefaultValue
,
Object
et
,
DEField
fieldAnnotation
)
throws
Exception
{
AuthenticationUser
curUser
=
AuthenticationUser
.
getAuthenticationUser
();
BeanMap
beanMap
=
BeanMap
.
create
(
et
);
Object
fieldValue
=
beanMap
.
get
(
fileName
);
//获取当前所需填充属性的get、set方法及字段值
PropertyDescriptor
field
=
new
PropertyDescriptor
(
fileName
,
et
.
getClass
());
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
)){
private
void
fillFieldDefaultValue
(
String
fieldname
,
DEFieldDefaultValueType
deFieldType
,
String
deFieldDefaultValue
,
EntityBase
et
,
AuthenticationUser
curUser
)
throws
Exception
{
Object
fieldValue
=
et
.
get
(
fieldname
);
if
(
org
.
springframework
.
util
.
ObjectUtils
.
isEmpty
(
fieldValue
)){
//填充直接值及其余默认值类型
if
(
(
deFieldType
==
DEFieldDefaultValueType
.
NONE
&&
!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
||
(
deFieldType
!=
DEFieldDefaultValueType
.
NONE
)
){
switch
(
deFieldType
){
case
SESSION:
String
sessionField
=
fieldAnnotation
.
defaultValue
();
if
(!
StringUtils
.
isEmpty
(
sessionField
)){
Object
sessionFieldValue
=
curUser
.
getSessionParams
().
get
(
sessionField
);
if
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
)){
Object
sessionFieldValue
=
curUser
.
getSessionParams
().
get
(
deFieldDefaultValue
.
toLowerCase
());
if
(!
ObjectUtils
.
isEmpty
(
sessionFieldValue
)){
beanMap
.
put
(
fileN
ame
,
sessionFieldValue
);
et
.
set
(
fieldn
ame
,
sessionFieldValue
);
}
}
break
;
...
...
@@ -220,146 +172,94 @@ public class DEFieldDefaultValueAspect
//暂未实现
break
;
case
UNIQUEID:
String
uuid
=(
new
AlternativeJdkIdGenerator
()).
generateId
().
toString
();
Object
objUuId
=
fieldValueConvert
(
uuid
,
field
);
beanMap
.
put
(
fileName
,
objUuId
);
et
.
set
(
fieldname
,(
new
AlternativeJdkIdGenerator
()).
generateId
().
toString
().
replace
(
"-"
,
""
));
break
;
case
CONTEXT:
//暂未实现
if
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
)){
Object
paramFieldValue
=
et
.
get
(
deFieldDefaultValue
);
if
(!
ObjectUtils
.
isEmpty
(
paramFieldValue
)){
et
.
set
(
fieldname
,
paramFieldValue
);
}
}
break
;
case
PARAM:
String
paramField
=
fieldAnnotation
.
defaultValue
();
if
(!
StringUtils
.
isEmpty
(
paramField
)){
Object
paramFieldValue
=
beanMap
.
get
(
paramField
);
if
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
)){
Object
paramFieldValue
=
et
.
get
(
deFieldDefaultValue
);
if
(!
ObjectUtils
.
isEmpty
(
paramFieldValue
)){
beanMap
.
put
(
fileN
ame
,
paramFieldValue
);
et
.
set
(
fieldn
ame
,
paramFieldValue
);
}
}
break
;
case
OPERATOR:
beanMap
.
put
(
fileN
ame
,
curUser
.
getUserid
());
et
.
set
(
fieldn
ame
,
curUser
.
getUserid
());
break
;
case
OPERATORNAME:
beanMap
.
put
(
fileN
ame
,
curUser
.
getPersonname
());
et
.
set
(
fieldn
ame
,
curUser
.
getPersonname
());
break
;
case
CURTIME:
beanMap
.
put
(
fileN
ame
,
new
Timestamp
(
new
Date
().
getTime
()));
et
.
set
(
fieldn
ame
,
new
Timestamp
(
new
Date
().
getTime
()));
break
;
case
APPDATA:
//暂未实现
break
;
case
NONE:
Object
deFieldDefaultValueObj
=
fieldValueConvert
(
deFieldDefaultValue
,
field
);
beanMap
.
put
(
fileName
,
deFieldDefaultValueObj
);
et
.
set
(
fieldname
,
deFieldDefaultValue
);
break
;
}
}
}
}
/**
* 填充系统预置属性
* @param fileName 实体属性名
* @param preFieldType 预置类型
* @param et 当前实体对象
* @param joinPoint 切点
* @param fieldAnnotation 属性注解
* @throws Exception
*/
private
void
fillPreFieldValue
(
String
fileName
,
DEPredefinedFieldType
preFieldType
,
Object
et
,
JoinPoint
joinPoint
,
DEField
fieldAnnotation
)
throws
Exception
{
AuthenticationUser
curUser
=
AuthenticationUser
.
getAuthenticationUser
();
BeanMap
beanMap
=
BeanMap
.
create
(
et
);
//当前操作行为
String
actionName
=
joinPoint
.
getSignature
().
getName
();
Object
fieldValue
=
beanMap
.
get
(
fileName
);
//获取当前所需填充属性的get、set方法及字段值
PropertyDescriptor
field
=
new
PropertyDescriptor
(
fileName
,
et
.
getClass
());
private
void
fillPreFieldValue
(
String
fieldname
,
DEPredefinedFieldType
preFieldType
,
EntityBase
et
,
String
actionName
,
String
logicValue
,
AuthenticationUser
curUser
)
throws
Exception
{
Object
fieldValue
=
et
.
get
(
fieldname
);
//为预置属性进行赋值
if
(
(
actionName
.
equalsIgnoreCase
(
"create"
)
&&
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
)
)||
if
(
actionName
.
equalsIgnoreCase
(
"create"
)||
preFieldType
==
DEPredefinedFieldType
.
UPDATEDATE
||
preFieldType
==
DEPredefinedFieldType
.
UPDATEMAN
||
preFieldType
==
DEPredefinedFieldType
.
UPDATEMANNAME
){
switch
(
preFieldType
){
//根据注解给预置属性填充值
case
CREATEMAN:
beanMap
.
put
(
fileN
ame
,
curUser
.
getUserid
());
et
.
set
(
fieldn
ame
,
curUser
.
getUserid
());
break
;
case
CREATEMANNAME:
beanMap
.
put
(
fileN
ame
,
curUser
.
getPersonname
());
et
.
set
(
fieldn
ame
,
curUser
.
getPersonname
());
break
;
case
UPDATEMAN:
beanMap
.
put
(
fileN
ame
,
curUser
.
getUserid
());
et
.
set
(
fieldn
ame
,
curUser
.
getUserid
());
break
;
case
UPDATEMANNAME:
beanMap
.
put
(
fileN
ame
,
curUser
.
getPersonname
());
et
.
set
(
fieldn
ame
,
curUser
.
getPersonname
());
break
;
case
CREATEDATE:
beanMap
.
put
(
fileN
ame
,
new
Timestamp
(
new
Date
().
getTime
()));
et
.
set
(
fieldn
ame
,
new
Timestamp
(
new
Date
().
getTime
()));
break
;
case
UPDATEDATE:
beanMap
.
put
(
fileN
ame
,
new
Timestamp
(
new
Date
().
getTime
()));
et
.
set
(
fieldn
ame
,
new
Timestamp
(
new
Date
().
getTime
()));
break
;
case
ORGID:
beanMap
.
put
(
fileName
,
curUser
.
getOrgid
());
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
et
.
set
(
fieldname
,
curUser
.
getOrgid
());
break
;
case
ORGNAME:
beanMap
.
put
(
fileName
,
curUser
.
getOrgname
());
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
et
.
set
(
fieldname
,
curUser
.
getOrgname
());
break
;
case
ORGSECTORID:
beanMap
.
put
(
fileName
,
curUser
.
getMdeptid
());
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
et
.
set
(
fieldname
,
curUser
.
getMdeptid
());
break
;
case
ORGSECTORNAME:
beanMap
.
put
(
fileName
,
curUser
.
getMdeptname
());
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
et
.
set
(
fieldname
,
curUser
.
getMdeptname
());
break
;
case
LOGICVALID:
String
logicValue
=
fieldAnnotation
.
logicval
();
Object
objLogicValue
=
fieldValueConvert
(
logicValue
,
field
);
if
(!
StringUtils
.
isEmpty
(
objLogicValue
)){
beanMap
.
put
(
fileName
,
objLogicValue
);
if
(!
StringUtils
.
isEmpty
(
logicValue
)){
logicValue
=
"1"
;
}
et
.
set
(
fieldname
,
logicValue
);
break
;
}
}
}
/**
* 值类型转换
* @param fieldValue
* @param field
*/
private
Object
fieldValueConvert
(
String
fieldValue
,
PropertyDescriptor
field
){
Object
resultValue
=
fieldValue
;
String
targetType
=
field
.
getPropertyType
().
getSimpleName
();
if
(
targetType
.
equals
(
"Boolean"
)){
resultValue
=
Boolean
.
valueOf
(
fieldValue
);
}
else
if
(
targetType
.
equals
(
"Character"
)){
resultValue
=
fieldValue
.
toCharArray
();
}
else
if
(
targetType
.
equals
(
"Byte"
)){
resultValue
=
Byte
.
valueOf
(
fieldValue
);
}
else
if
(
targetType
.
equals
(
"Short"
)){
resultValue
=
Short
.
valueOf
(
fieldValue
);
}
else
if
(
targetType
.
equals
(
"Integer"
)){
resultValue
=
Integer
.
valueOf
(
fieldValue
);
}
else
if
(
targetType
.
equals
(
"Long"
)){
resultValue
=
Long
.
valueOf
(
fieldValue
);
}
else
if
(
targetType
.
equals
(
"Float"
)){
resultValue
=
Float
.
valueOf
(
fieldValue
);
}
else
if
(
targetType
.
equals
(
"Double"
)){
resultValue
=
Double
.
valueOf
(
fieldValue
);
}
return
resultValue
;
}
}
ibzwf-util/src/main/java/cn/ibizlab/util/helper/DEFieldCacheMap.java
浏览文件 @
f56f42cd
...
...
@@ -2,8 +2,8 @@ package cn.ibizlab.util.helper;
import
cn.ibizlab.util.annotation.DEField
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.Hashtable
;
...
...
@@ -20,6 +20,10 @@ public class DEFieldCacheMap {
private
static
Hashtable
<
String
,
Hashtable
<
String
,
String
>>
cacheKey
=
new
Hashtable
<>();
private
static
Hashtable
<
String
,
Hashtable
<
String
,
DEField
>>
cacheDEField
=
new
Hashtable
<>();
private
static
Hashtable
<
String
,
String
>
cacheDEKeyField
=
new
Hashtable
<>();
private
static
Object
objLock1
=
new
Object
();
/**
...
...
@@ -39,15 +43,24 @@ public class DEFieldCacheMap {
Hashtable
<
String
,
Field
>
result
=
new
Hashtable
<
String
,
Field
>();
List
<
Field
>
list
=
new
ArrayList
<
Field
>();
Hashtable
<
String
,
String
>
keys
=
new
Hashtable
<
String
,
String
>();
Hashtable
<
String
,
DEField
>
defields
=
new
Hashtable
<>();
Hashtable
<
String
,
String
>
dekeyfields
=
new
Hashtable
<>();
Field
[]
fields
=
clazz
.
getDeclaredFields
();
for
(
Field
field:
fields
){
result
.
put
(
field
.
getName
(),
field
);
list
.
add
(
field
);
keys
.
put
(
field
.
getName
().
toLowerCase
(),
field
.
getName
());
DEField
deField
=
field
.
getAnnotation
(
DEField
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
deField
))
{
defields
.
put
(
field
.
getName
(),
deField
);
if
(
deField
.
isKeyField
())
cacheDEKeyField
.
put
(
className
,
field
.
getName
());
}
}
cacheMap
.
put
(
className
,
result
);
cacheList
.
put
(
className
,
list
);
cacheKey
.
put
(
className
,
keys
);
cacheDEField
.
put
(
className
,
defields
);
return
result
;
}
}
...
...
@@ -67,6 +80,41 @@ public class DEFieldCacheMap {
}
}
/**
* 从缓存中查询实体对象属性集合
* @param
* @return
*/
public
static
<
T
>
Hashtable
<
String
,
DEField
>
getDEFields
(
Class
<
T
>
clazz
)
{
String
className
=
clazz
.
getName
();
if
(
className
.
indexOf
(
"_$"
)>
0
)
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
if
(
cacheDEField
.
containsKey
(
className
))
return
cacheDEField
.
get
(
className
);
else
{
DEFieldCacheMap
.
getFieldMap
(
clazz
);
return
cacheDEField
.
get
(
className
);
}
}
/**
* 从缓存中查询实体对象主键
* @param
* @return
*/
public
static
<
T
>
String
getDEKeyField
(
Class
<
T
>
clazz
)
{
String
className
=
clazz
.
getName
();
if
(
className
.
indexOf
(
"_$"
)>
0
)
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
if
(
cacheDEKeyField
.
containsKey
(
className
))
return
cacheDEKeyField
.
get
(
className
);
else
{
DEFieldCacheMap
.
getFieldMap
(
clazz
);
return
cacheDEKeyField
.
get
(
className
);
}
}
/**
* 从缓存中查询实体对象属性列表
* @param
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录