|
|
|
|
@ -3,11 +3,15 @@ package cn.iocoder.yudao.framework.common.util.spring;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
|
import org.aspectj.lang.JoinPoint;
|
|
|
|
|
import org.aspectj.lang.reflect.MethodSignature;
|
|
|
|
|
import org.springframework.context.expression.BeanFactoryResolver;
|
|
|
|
|
import org.springframework.core.DefaultParameterNameDiscoverer;
|
|
|
|
|
import org.springframework.core.ParameterNameDiscoverer;
|
|
|
|
|
import org.springframework.expression.EvaluationContext;
|
|
|
|
|
import org.springframework.expression.Expression;
|
|
|
|
|
import org.springframework.expression.ExpressionParser;
|
|
|
|
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
|
|
|
|
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
|
|
|
|
@ -86,4 +90,20 @@ public class SpringExpressionUtils {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 从 Bean 工厂,解析 EL 表达式的结果
|
|
|
|
|
*
|
|
|
|
|
* @param expressionString EL 表达式
|
|
|
|
|
* @return 执行界面
|
|
|
|
|
*/
|
|
|
|
|
public static Object parseExpression(String expressionString) {
|
|
|
|
|
if (StrUtil.isBlank(expressionString)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
Expression expression = EXPRESSION_PARSER.parseExpression(expressionString);
|
|
|
|
|
StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
|
|
context.setBeanResolver(new BeanFactoryResolver(SpringUtil.getApplicationContext()));
|
|
|
|
|
return expression.getValue(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|