|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
package cn.estsh.i3plus.pojo.base.dynamic;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
|
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import javax.persistence.Transient;
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
@ -28,6 +30,8 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
|
|
|
|
|
public String tableName;
|
|
|
|
|
public List<String> propertyList;
|
|
|
|
|
@ApiParam(value ="子集列表")
|
|
|
|
|
private List<DynamicEntity> childList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
public DynamicEntity(){
|
|
|
|
|
try {
|
|
|
|
@ -42,13 +46,6 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
this.tableName = tableName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getTableName() {
|
|
|
|
|
return tableName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTableName(String tableName) {
|
|
|
|
|
this.tableName = tableName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 初始化属性,以便动态加载
|
|
|
|
@ -60,8 +57,7 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
Field[] fields = this.getClass().getDeclaredFields();
|
|
|
|
|
for(Field f : fields) {
|
|
|
|
|
String propName = f.getName().replace(ATTR_PREFIX, "");
|
|
|
|
|
if(!"LOGGER".equals(propName) && !"ATTR_PREFIX".equals(propName)
|
|
|
|
|
&& !"propertyList".equals(propName) && !"dynProperty".equals(propName) ) {
|
|
|
|
|
if (!isDefaultField(propName)) {
|
|
|
|
|
// 添加到属性list中
|
|
|
|
|
this.getPropertyList().add(propName);
|
|
|
|
|
// 属性初始化
|
|
|
|
@ -77,8 +73,7 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
Field[] fields = this.getClass().getDeclaredFields();
|
|
|
|
|
for(Field f : fields) {
|
|
|
|
|
String fieldName = f.getName().replace(ATTR_PREFIX, "");
|
|
|
|
|
if (!"LOGGER".equals(fieldName) && !"ATTR_PREFIX".equals(fieldName)
|
|
|
|
|
&& !"propertyList".equals(fieldName) && !"dynProperty".equals(fieldName)) {
|
|
|
|
|
if (!isDefaultField(fieldName)) {
|
|
|
|
|
|
|
|
|
|
result += "\"" + fieldName + "\":\"" + getDynProperty(fieldName) + "\",";
|
|
|
|
|
}
|
|
|
|
@ -92,7 +87,6 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setDynProperty(Map<String,Object> params) {
|
|
|
|
|
if (params != null && params.size() > 0){
|
|
|
|
|
params.forEach((k,v)->{{
|
|
|
|
@ -140,14 +134,6 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
return getValue(propName,result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getPropertyList() {
|
|
|
|
|
return propertyList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPropertyList(List<String> propertyList) {
|
|
|
|
|
this.propertyList = propertyList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取默认值
|
|
|
|
|
* @param propName
|
|
|
|
@ -188,4 +174,43 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 是否是本类属性
|
|
|
|
|
* @param fieldName
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public boolean isDefaultField(String fieldName){
|
|
|
|
|
if (!ATTR_PREFIX.equals(fieldName)) {
|
|
|
|
|
if("propertyList".equals(fieldName) || "dynProperty".equals(fieldName) || "childList".equals(fieldName)
|
|
|
|
|
|| "LOGGER".equals(fieldName)){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getTableName() {
|
|
|
|
|
return tableName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTableName(String tableName) {
|
|
|
|
|
this.tableName = tableName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getPropertyList() {
|
|
|
|
|
return propertyList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPropertyList(List<String> propertyList) {
|
|
|
|
|
this.propertyList = propertyList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<DynamicEntity> getChildList() {
|
|
|
|
|
return childList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setChildList(List<DynamicEntity> childList) {
|
|
|
|
|
this.childList = childList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|