对象转Map
public static Map<String, Object> objectToMap(Object obj) throws Exception {
if(obj == null){
return null;
}
Map<String, Object> map = new HashMap<>();
Field[] declaredFields = obj.getClass().getDeclaredFields();
for (Field field : declaredFields) {
field.setAccessible(true);
map.put(field.getName(), field.get(obj));
}
return map;
}