fix: 修复发送通知时没有获取到表里最新的值的问题

--bug=1008988 --user=刘瑞斌 【消息通知】删除接口用例无删除时间删除人ID,以及创建人ID,标签 https://www.tapd.cn/55049933/s/1084364
This commit is contained in:
CaptainB 2021-12-21 16:35:57 +08:00 committed by 刘瑞斌
parent 4142a2a8d0
commit 083bc8f9e9
1 changed files with 22 additions and 0 deletions

View File

@ -101,6 +101,28 @@ public class SendNoticeAspect {
String[] params = discoverer.getParameterNames(method);
//获取操作
SendNotice sendNotice = method.getAnnotation(SendNotice.class);
// 再次从数据库查询一次内容方便获取最新参数
InvocationHandler invocationHandler = Proxy.getInvocationHandler(sendNotice);
Field value = invocationHandler.getClass().getDeclaredField("memberValues");
value.setAccessible(true);
if (StringUtils.isNotEmpty(sendNotice.target())) {
//将参数纳入Spring管理
EvaluationContext context = new StandardEvaluationContext();
for (int len = 0; len < params.length; len++) {
context.setVariable(params[len], args[len]);
}
context.setVariable("targetClass", CommonBeanFactory.getBean(sendNotice.targetClass()));
String target = sendNotice.target();
Expression titleExp = parser.parseExpression(target);
Object v = titleExp.getValue(context, Object.class);
if (v != null) {
Map<String, Object> memberValues = (Map<String, Object>) value.get(invocationHandler);
memberValues.put("source", JSON.toJSONString(v));
}
}
EvaluationContext context = new StandardEvaluationContext();
for (int len = 0; len < params.length; len++) {
context.setVariable(params[len], args[len]);