|
|
|
@ -64,69 +64,6 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取当前对象
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*//*
|
|
|
|
|
public DynamicEntity get(String method, String uri, Object[] args, Object result, String operator, String appName) {
|
|
|
|
|
setMethod(method);
|
|
|
|
|
setUri(uri);
|
|
|
|
|
setArgs(args);
|
|
|
|
|
setResult(result);
|
|
|
|
|
setOperator(operator);
|
|
|
|
|
setAppName(appName);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getMethod() {
|
|
|
|
|
return method;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMethod(String method) {
|
|
|
|
|
this.method = method;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getUri() {
|
|
|
|
|
return uri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setUri(String uri) {
|
|
|
|
|
this.uri = uri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object[] getArgs() {
|
|
|
|
|
return args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setArgs(Object[] args) {
|
|
|
|
|
this.args = args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object getResult() {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setResult(Object result) {
|
|
|
|
|
this.result = result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getOperator() {
|
|
|
|
|
return operator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setOperator(String operator) {
|
|
|
|
|
this.operator = operator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getAppName() {
|
|
|
|
|
return appName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAppName(String appName) {
|
|
|
|
|
this.appName = appName;
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 初始化属性,以便动态加载
|
|
|
|
|
* @throws InvocationTargetException
|
|
|
|
|
* @throws IllegalAccessException
|
|
|
|
@ -134,18 +71,15 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
*/
|
|
|
|
|
public void initDynamic() {
|
|
|
|
|
Field[] fields = this.getClass().getDeclaredFields();
|
|
|
|
|
|
|
|
|
|
Method setMethod = null;
|
|
|
|
|
String setMethodName,propName;
|
|
|
|
|
Object fieldVal = null;
|
|
|
|
|
|
|
|
|
|
for(Field f : fields) {
|
|
|
|
|
propName = f.getName().replace("$cglib_prop_", "");
|
|
|
|
|
if(!"LOGGER".equals(propName) && !"propertyList".equals(propName)) {
|
|
|
|
|
if(!"LOGGER".equals(propName) && !"propertyList".equals(propName) && !"dynProperty".equals(propName)) {
|
|
|
|
|
this.getPropertyList().add(propName); //添加到属性list中
|
|
|
|
|
|
|
|
|
|
setMethodName = "set" + propName.substring(0,1).toUpperCase() + propName.substring(1);
|
|
|
|
|
|
|
|
|
|
f.setAccessible(true);
|
|
|
|
|
try {
|
|
|
|
|
fieldVal = f.get(this);
|
|
|
|
@ -163,9 +97,9 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
} else if (f.getType() == Double.class) {
|
|
|
|
|
fieldVal = 0.0d;
|
|
|
|
|
} else if (f.getType() == String.class) {
|
|
|
|
|
fieldVal = "1";
|
|
|
|
|
fieldVal = "";
|
|
|
|
|
}else if (f.getType() == Character.class) {
|
|
|
|
|
fieldVal = "1";
|
|
|
|
|
fieldVal = "";
|
|
|
|
|
}else if (f.getType() == Boolean.class) {
|
|
|
|
|
fieldVal = true;
|
|
|
|
|
}else if (f.getType() == Byte.class) {
|
|
|
|
@ -173,7 +107,7 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
}else if (f.getType() == Date.class) {
|
|
|
|
|
fieldVal = new Date();
|
|
|
|
|
}else {
|
|
|
|
|
fieldVal = "1";
|
|
|
|
|
fieldVal = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -261,21 +195,19 @@ public class DynamicEntity extends BaseBean implements Serializable {
|
|
|
|
|
* @throws NoSuchMethodException
|
|
|
|
|
*/
|
|
|
|
|
public void setDynProperty(String propName,Object val){
|
|
|
|
|
if(StringUtils.isNotBlank(propName) && val != null){
|
|
|
|
|
//初始化set方法
|
|
|
|
|
String setMethodName = "set" + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, propName);
|
|
|
|
|
//获取方法
|
|
|
|
|
Method setMethod = null;
|
|
|
|
|
try {
|
|
|
|
|
setMethod = this.getClass().getDeclaredMethod(setMethodName, new Class[]{val.getClass()});
|
|
|
|
|
setMethod.invoke(this, val);
|
|
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
|
|
LOGGER.error("没有方法:{}",setMethodName,e);
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
LOGGER.error("入参出错:{}:{}",val,val.getClass(),e);
|
|
|
|
|
} catch (InvocationTargetException e) {
|
|
|
|
|
LOGGER.error("方法返回出错:{}",setMethodName,e);
|
|
|
|
|
}
|
|
|
|
|
//初始化set方法
|
|
|
|
|
String setMethodName = "set" + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, propName);
|
|
|
|
|
//获取方法
|
|
|
|
|
Method setMethod = null;
|
|
|
|
|
try {
|
|
|
|
|
setMethod = this.getClass().getDeclaredMethod(setMethodName, new Class[]{val.getClass()});
|
|
|
|
|
setMethod.invoke(this, val);
|
|
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
|
|
LOGGER.error("没有方法:{}",setMethodName,e);
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
LOGGER.error("入参出错:{}:{}",val,val.getClass(),e);
|
|
|
|
|
} catch (InvocationTargetException e) {
|
|
|
|
|
LOGGER.error("方法返回出错:{}",setMethodName,e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|