Commit 8597907f authored by suhuiguang's avatar suhuiguang

fix(大编辑):bug修复

1.比较
parent e97c1d15
...@@ -8,6 +8,8 @@ import java.util.Objects; ...@@ -8,6 +8,8 @@ import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiPredicate; import java.util.function.BiPredicate;
import static com.yeejoin.amos.boot.module.jg.biz.edit.utils.JsonDiffUtil.isNullOrEmpty;
public class DiffUtils { public class DiffUtils {
private static final Map<String, BiPredicate<String, String>> diffCache = new ConcurrentHashMap<>(); private static final Map<String, BiPredicate<String, String>> diffCache = new ConcurrentHashMap<>();
...@@ -25,7 +27,9 @@ public class DiffUtils { ...@@ -25,7 +27,9 @@ public class DiffUtils {
} }
public static boolean compare(String type, String newValue, String oldValue) { public static boolean compare(String type, String newValue, String oldValue) {
if (type == null || newValue == null || oldValue == null) { if (isNullOrEmpty(newValue) && isNullOrEmpty(oldValue)) return true;
if (isNullOrEmpty(newValue) || isNullOrEmpty(oldValue)) return true;
if (type == null) {
return Objects.equals(newValue, oldValue); return Objects.equals(newValue, oldValue);
} }
return diffCache.getOrDefault(type, Objects::equals).test(newValue, oldValue); return diffCache.getOrDefault(type, Objects::equals).test(newValue, oldValue);
......
...@@ -114,7 +114,7 @@ public class JsonDiffUtil { ...@@ -114,7 +114,7 @@ public class JsonDiffUtil {
} }
} }
private static boolean isNullOrEmpty(String str) { public static boolean isNullOrEmpty(String str) {
return str == null || str.trim().isEmpty() || "null".equals(str); return str == null || str.trim().isEmpty() || "null".equals(str);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment