From 8d7d900289c57f5261046907b34b720c5dca53e3 Mon Sep 17 00:00:00 2001 From: fighter-wang <118291973+fighter-wang@users.noreply.github.com> Date: Thu, 9 May 2024 19:23:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=9F=AD=E4=BF=A1=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=A8=A1=E5=9D=97):=20=E4=BF=AE=E5=A4=8D=E4=BA=A7=E5=93=81/?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=8F=91=E7=94=9F=E5=91=8A=E8=AD=A6=EF=BC=8C?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E9=80=9A=E7=9F=A5=E5=86=85=E7=BD=AE=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E6=9C=AA=E8=BF=9B=E8=A1=8C=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#507)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/notify/template/Template.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/template/Template.java b/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/template/Template.java index 1edd1a879..61caca3d0 100755 --- a/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/template/Template.java +++ b/jetlinks-components/notify-component/notify-core/src/main/java/org/jetlinks/community/notify/template/Template.java @@ -62,7 +62,18 @@ default String get(String key, } default Map renderMap(Map context) { - return Maps.transformValues(context, value -> value == null ? null: VariableSource.of(value).resolveStatic(context)); + return Maps.transformEntries(context, (key, value) -> + Optional.ofNullable(value) + .map(val -> VariableSource.of(val).resolveStatic(context)) + .map(val -> { + Optional variableDefOpt = getVariable(key); + if (variableDefOpt.isPresent()) { + return variableDefOpt.get().convertValue(val); + } + return val; + }) + .orElse(null) + ); } default String convert(String key, Object value) {