|
@@ -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 org.aspectj.lang.JoinPoint;
|
|
|
import org.aspectj.lang.reflect.MethodSignature;
|
|
|
+import org.springframework.beans.factory.BeanFactory;
|
|
|
+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,21 @@ public class SpringExpressionUtils {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 从 Bean 工厂,解析 EL 表达式的结果
|
|
|
+ *
|
|
|
+ * @param beanFactory Bean 工程
|
|
|
+ * @param expressionString EL 表达式
|
|
|
+ * @return 执行界面
|
|
|
+ */
|
|
|
+ public static Object parseExpression(BeanFactory beanFactory, String expressionString) {
|
|
|
+ if (StrUtil.isBlank(expressionString)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Expression expression = EXPRESSION_PARSER.parseExpression(expressionString);
|
|
|
+ StandardEvaluationContext context = new StandardEvaluationContext();
|
|
|
+ context.setBeanResolver(new BeanFactoryResolver(beanFactory));
|
|
|
+ return expression.getValue(context);
|
|
|
+ }
|
|
|
+
|
|
|
}
|