|
|
@@ -7,6 +7,7 @@ import cn.hutool.core.util.ArrayUtil; |
|
|
|
import cn.hutool.core.util.ObjUtil; |
|
|
|
import lombok.Builder; |
|
|
|
import lombok.Data; |
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
@@ -47,8 +48,11 @@ public final class ProjectDetailDiffUtil { |
|
|
|
* @return 对比结果 |
|
|
|
**/ |
|
|
|
public static List<FieldDiff> diff(Object oldObj, Object newObj, boolean diffSame, String... ignores) { |
|
|
|
Map<String, Object> oldObjMap = BeanUtil.beanToMap(oldObj); |
|
|
|
Map<String, Object> newObjMap = BeanUtil.beanToMap(newObj); |
|
|
|
if (oldObj == null && newObj == null) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
Map<String, Object> oldObjMap = oldObj == null ? Collections.emptyMap() : BeanUtil.beanToMap(oldObj); |
|
|
|
Map<String, Object> newObjMap = newObj == null ? Collections.emptyMap() : BeanUtil.beanToMap(newObj); |
|
|
|
if (ArrayUtil.isNotEmpty(ignores)) { |
|
|
|
for (String ignore : ignores) { |
|
|
|
newObjMap.remove(ignore); |
|
|
|