mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-20 16:56:02 +08:00
修改表达式获取方式
This commit is contained in:
@@ -28,6 +28,7 @@ import org.hswebframework.expands.script.engine.DynamicScriptEngine;
|
||||
import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory;
|
||||
import org.hswebframework.utils.ClassUtils;
|
||||
import org.hswebframework.utils.StringUtils;
|
||||
import org.hswebframework.web.ExpressionUtils;
|
||||
import org.hswebframework.web.authorization.Authentication;
|
||||
import org.hswebframework.web.authorization.Permission;
|
||||
import org.hswebframework.web.authorization.Role;
|
||||
@@ -149,22 +150,27 @@ public class SimpleAuthorizeMethodInterceptor extends AuthorizingAnnotationMetho
|
||||
}
|
||||
|
||||
public String tryCompileExpression(String express) {
|
||||
if (express.startsWith("${") && express.endsWith("}")) {
|
||||
express = express.substring(2, express.length() - 1);
|
||||
DynamicScriptEngine spelEngine = DynamicScriptEngineFactory.getEngine("spel");
|
||||
String id = DigestUtils.md5Hex(express);
|
||||
try {
|
||||
if (!spelEngine.compiled(id))
|
||||
spelEngine.compile(id, express);
|
||||
return String.valueOf(spelEngine.execute(id, var).getIfSuccess());
|
||||
} catch (Exception e) {
|
||||
throw new AuthorizationException("系统错误", e);
|
||||
} finally {
|
||||
// spelEngine.remove(id);
|
||||
}
|
||||
} else {
|
||||
return express;
|
||||
try {
|
||||
return ExpressionUtils.analytical(express, var, "spel");
|
||||
} catch (Exception e) {
|
||||
throw new AuthorizationException("系统错误", e);
|
||||
}
|
||||
// if (express.startsWith("${") && express.endsWith("}")) {
|
||||
// express = express.substring(2, express.length() - 1);
|
||||
// DynamicScriptEngine spelEngine = DynamicScriptEngineFactory.getEngine("spel");
|
||||
// String id = DigestUtils.md5Hex(express);
|
||||
// try {
|
||||
// if (!spelEngine.compiled(id))
|
||||
// spelEngine.compile(id, express);
|
||||
// return String.valueOf(spelEngine.execute(id, var).getIfSuccess());
|
||||
// } catch (Exception e) {
|
||||
// throw new AuthorizationException("系统错误", e);
|
||||
// } finally {
|
||||
// // spelEngine.remove(id);
|
||||
// }
|
||||
// } else {
|
||||
// return express;
|
||||
// }
|
||||
}
|
||||
|
||||
public Collection<String> tryCompileExpression(String... expresses) {
|
||||
|
||||
Reference in New Issue
Block a user