From 083bc8f9e9e28452de1bfa47a1fc58e9fbb40eff Mon Sep 17 00:00:00 2001 From: CaptainB Date: Tue, 21 Dec 2021 16:35:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=91=E9=80=81?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=97=B6=E6=B2=A1=E6=9C=89=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=88=B0=E8=A1=A8=E9=87=8C=E6=9C=80=E6=96=B0=E7=9A=84=E5=80=BC?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1008988 --user=刘瑞斌 【消息通知】删除接口用例无删除时间删除人ID,以及创建人ID,标签 https://www.tapd.cn/55049933/s/1084364 --- .../notice/sender/SendNoticeAspect.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/backend/src/main/java/io/metersphere/notice/sender/SendNoticeAspect.java b/backend/src/main/java/io/metersphere/notice/sender/SendNoticeAspect.java index c634e20a80..dd62d85463 100644 --- a/backend/src/main/java/io/metersphere/notice/sender/SendNoticeAspect.java +++ b/backend/src/main/java/io/metersphere/notice/sender/SendNoticeAspect.java @@ -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 memberValues = (Map) 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]);