1. 管理后台,增加租户管理

2. 修复大量因为租户报错的单元测试
This commit is contained in:
YunaiV
2021-12-14 22:39:43 +08:00
parent a582a6e726
commit 098c5b4723
45 changed files with 1240 additions and 178 deletions

View File

@ -1,7 +1,9 @@
package cn.iocoder.yudao.framework.common.util.object;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReflectUtil;
import java.lang.reflect.Field;
import java.util.function.Consumer;
/**
@ -11,8 +13,21 @@ import java.util.function.Consumer;
*/
public class ObjectUtils {
public static <T> T clone(T object, Consumer<T> consumer) {
/**
* 复制对象,并忽略 Id 编号
*
* @param object 被复制对象
* @param consumer 消费者,可以二次编辑被复制对象
* @return 复制后的对象
*/
public static <T> T cloneIgnoreId(T object, Consumer<T> consumer) {
T result = ObjectUtil.clone(object);
// 忽略 id 编号
Field field = ReflectUtil.getField(object.getClass(), "id");
if (field != null) {
ReflectUtil.setFieldValue(result, field, null);
}
// 二次编辑
if (result != null) {
consumer.accept(result);
}