【7.2.5】【rule】抽出通用的一个方法

pull/37/head
fengshuonan 2022-09-07 11:07:30 +08:00
parent ffd149e4dc
commit 53e5512eb5
2 changed files with 30 additions and 17 deletions

View File

@ -0,0 +1,28 @@
package cn.stylefeng.roses.kernel.rule.util;
import java.lang.reflect.Array;
/**
*
*
* @author fengshuonan
* @date 2022/9/7 11:06
*/
public class ObjectConvertUtil {
/**
* Objectarrayobject
*
* @author fengshuonan
* @date 2020/7/24 22:06
*/
public static Object[] objToArray(Object object) {
int length = Array.getLength(object);
Object[] result = new Object[length];
for (int i = 0; i < result.length; i++) {
result[i] = Array.get(object, i);
}
return result;
}
}

View File

@ -29,6 +29,7 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.util.ObjectConvertUtil;
import cn.stylefeng.roses.kernel.wrapper.api.BaseWrapper;
import cn.stylefeng.roses.kernel.wrapper.api.annotation.Wrapper;
import cn.stylefeng.roses.kernel.wrapper.api.exception.WrapperException;
@ -41,7 +42,6 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
@ -170,7 +170,7 @@ public class WrapperAop {
else if (ArrayUtil.isArray(beWrapped)) {
// 获取原有的Array
Object[] objects = this.objToArray(beWrapped);
Object[] objects = ObjectConvertUtil.objToArray(beWrapped);
// 将array中所有records都包装一遍
ArrayList<Map<String, Object>> maps = new ArrayList<>();
@ -219,19 +219,4 @@ public class WrapperAop {
return originMap;
}
/**
* Objectarrayobject
*
* @author fengshuonan
* @date 2020/7/24 22:06
*/
private Object[] objToArray(Object object) {
int length = Array.getLength(object);
Object[] result = new Object[length];
for (int i = 0; i < result.length; i++) {
result[i] = Array.get(object, i);
}
return result;
}
}