联调修改
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* 反射工具类
|
||||
*/
|
||||
public class ObjectFieldUtils {
|
||||
public static String getValue(Object obj,String fieldName){
|
||||
Field field=null;
|
||||
try{
|
||||
field=obj.getClass().getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return String.valueOf(field.get(obj)==null?"":field.get(obj));
|
||||
}catch (Exception e){
|
||||
if(obj.getClass().getSuperclass()!=Object.class){
|
||||
try{
|
||||
field=obj.getClass().getSuperclass().getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return String.valueOf(field.get(obj)==null?"":field.get(obj));
|
||||
}catch (Exception e1){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setValue(Object obj,String fieldName,Object value){
|
||||
Field field=null;
|
||||
try{
|
||||
field=obj.getClass().getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
field.set(obj,value);
|
||||
}catch (Exception e){
|
||||
if(obj.getClass().getSuperclass()!=Object.class){
|
||||
try{
|
||||
field=obj.getClass().getSuperclass().getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
field.set(obj,value);
|
||||
}catch (Exception e1){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user