提交 ded9b0e3 编写于 作者: zhouweidong's avatar zhouweidong

动态行为

上级 118f54b5
......@@ -97,16 +97,23 @@ public class DELogicAspect {
public void dynamicCall(JoinPoint point) {
Object args[] = point.getArgs();
if (!ObjectUtils.isEmpty(args) || args.length == 3) {
Object action = args[1];
Object id = args[0];
String action = String.valueOf(args[1]);
Object entity = args[2];
log.debug("开始执行实体动态行为[{}:{}]", entity.getClass().getSimpleName(), action);
EvaluationContext context = new StandardEvaluationContext();
context.setVariable("service", point.getTarget());
context.setVariable("action", action);
context.setVariable("entity", entity);
Expression oldExp = parser.parseExpression(String.format("#service.%s(#entity)", action));
oldExp.getValue(context);
log.debug("实体动态行为[{}:{}]执行结束", entity.getClass().getSimpleName(), action);
if (entity instanceof EntityBase) {
log.debug("开始执行实体动态行为[{}:{}]", entity.getClass().getSimpleName(), action);
EvaluationContext context = new StandardEvaluationContext();
context.setVariable("service", point.getTarget());
context.setVariable("action", action);
if ("remove".equalsIgnoreCase(action) || "get".equalsIgnoreCase(action)) {
context.setVariable("args", id);
} else {
context.setVariable("args", entity);
}
Expression oldExp = parser.parseExpression(String.format("#service.%s(#args)", action));
oldExp.getValue(context);
log.debug("实体动态行为[{}:{}]执行结束", entity.getClass().getSimpleName(), action);
}
}
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册