|
@@ -2,6 +2,7 @@ package com.persagy.dmp.basic.utils;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.fasterxml.jackson.databind.JavaType;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@@ -10,7 +11,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.persagy.dmp.common.constant.ResponseCode;
|
|
|
import com.persagy.dmp.common.exception.BusinessException;
|
|
|
import com.persagy.dmp.common.helper.SpringHelper;
|
|
|
-import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.lang.reflect.Field;
|
|
@@ -30,7 +30,7 @@ public class JsonNodeUtils {
|
|
|
* @param extraColumns 扩展属性中包含的列。为空表示所有非对象的列
|
|
|
* @return Json对象
|
|
|
*/
|
|
|
- public static ObjectNode toObjectNode(BaseEntity vo, String extraColumn, Set<String> extraColumns) {
|
|
|
+ public static ObjectNode toObjectNode(Object vo, String extraColumn, Set<String> extraColumns) {
|
|
|
if(vo == null) {
|
|
|
return null;
|
|
|
}
|
|
@@ -54,7 +54,7 @@ public class JsonNodeUtils {
|
|
|
* @param extraColumns 扩展属性中包含的列。为空表示所有非对象的列
|
|
|
* @return Json对象
|
|
|
*/
|
|
|
- public static List<ObjectNode> toListNode(List<BaseEntity> voList, String extraColumn, Set<String> extraColumns) {
|
|
|
+ public static List<ObjectNode> toListNode(List<Object> voList, String extraColumn, Set<String> extraColumns) {
|
|
|
if(CollUtil.isEmpty(voList)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -82,7 +82,7 @@ public class JsonNodeUtils {
|
|
|
* @param extraColumns 扩展属性中包含的列。为空表示所有非对象的列
|
|
|
* @return Json对象
|
|
|
*/
|
|
|
- public static ArrayNode toArrayNode(List<BaseEntity> voList, String extraColumn, Set<String> extraColumns) {
|
|
|
+ public static ArrayNode toArrayNode(List<Object> voList, String extraColumn, Set<String> extraColumns) {
|
|
|
if(CollUtil.isEmpty(voList)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -109,6 +109,10 @@ public class JsonNodeUtils {
|
|
|
* @param extraColumns 扩展属性中包含的列。为空表示所有非对象的列
|
|
|
*/
|
|
|
private static void ensureExtras(ObjectNode node, String extraColumn, Set<String> extraColumns) {
|
|
|
+ // 没有扩展列不用处理
|
|
|
+ if(StrUtil.isBlank(extraColumn)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
JsonNode extraNode = node.get(extraColumn);
|
|
|
// 如果扩展列的值为空或不是对象,直接返回
|
|
|
if(extraNode == null || extraNode.isNull() || !extraNode.isObject()) {
|