提交 c5413ad8 编写于 作者: misaka's avatar misaka

DynaProperty字段缓存

上级 1cbe557e
......@@ -3,6 +3,7 @@ package cn.ibizlab.businesscentral.util.helper;
import cn.ibizlab.businesscentral.util.annotation.Audit;
import cn.ibizlab.businesscentral.util.annotation.DEField;
import cn.ibizlab.businesscentral.util.annotation.DynaProperty;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.lang.reflect.Field;
......@@ -25,6 +26,8 @@ public class DEFieldCacheMap {
private static Hashtable<String, Hashtable<String,Audit>> cacheAuditField = new Hashtable<>();
private static Hashtable<String, Hashtable<String, DynaProperty>> cacheDynaPropertyField = new Hashtable<>();
private static Hashtable<String, String> cacheDEKeyField = new Hashtable<>();
private static Object objLock1=new Object();
......@@ -48,6 +51,7 @@ public class DEFieldCacheMap {
Hashtable<String,String> keys=new Hashtable<String,String>();
Hashtable<String,DEField> defields=new Hashtable<>();
Hashtable<String, Audit> auditfields=new Hashtable<>();
Hashtable<String, DynaProperty> dynapropertyfields=new Hashtable<>();
Hashtable<String,String> dekeyfields=new Hashtable<>();
Field[] fields=clazz.getDeclaredFields();
for(Field field:fields){
......@@ -56,6 +60,7 @@ public class DEFieldCacheMap {
keys.put(field.getName().toLowerCase(),field.getName());
DEField deField=field.getAnnotation(DEField.class);
Audit auditField=field.getAnnotation(Audit.class);
DynaProperty dynaPropertyField=field.getAnnotation(DynaProperty.class);
if(!ObjectUtils.isEmpty(deField)) {
defields.put(field.getName(),deField);
if(deField.isKeyField())
......@@ -64,12 +69,16 @@ public class DEFieldCacheMap {
if(!ObjectUtils.isEmpty(auditField)) {
auditfields.put(field.getName(),auditField);
}
if(!ObjectUtils.isEmpty(dynaPropertyField)){
dynapropertyfields.put(field.getName(),dynaPropertyField) ;
}
}
cacheMap.put(className, result);
cacheList.put(className,list);
cacheKey.put(className,keys);
cacheDEField.put(className,defields);
cacheAuditField.put(className,auditfields);
cacheDynaPropertyField.put(className,dynapropertyfields);
return result;
}
}
......@@ -123,6 +132,23 @@ public class DEFieldCacheMap {
}
}
/**
* 从缓存中查询审计属性集合
* @param
* @return
*/
public static <T> Hashtable<String,DynaProperty> getDynaPropertyFields(Class<T> clazz) {
String className=clazz.getName();
if(className.indexOf("_$")>0)
className=className.substring(0, className.lastIndexOf("_$"));
if(cacheDynaPropertyField.containsKey(className))
return cacheDynaPropertyField.get(className);
else{
DEFieldCacheMap.getFieldMap(className);
return cacheDynaPropertyField.get(className);
}
}
/**
* 从缓存中查询实体对象主键
* @param
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册