From 5c835e1805e3cb0560c0a6c120866d37a4af58a1 Mon Sep 17 00:00:00 2001 From: wangshaoping Date: Thu, 10 Jul 2025 11:23:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E7=A1=80=E6=A1=86=E6=9E=B6=E5=8F=91?= =?UTF-8?q?=E5=B8=83:=208.2.23=20=20=201)=20=E8=A7=84=E5=88=99=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E4=B8=AD,=20=E4=BF=AE=E5=A4=8D=E6=8C=87=E6=A0=87?= =?UTF-8?q?=E5=BA=93=E5=8F=82=E6=95=B0=E6=9E=84=E5=BB=BA=E5=99=A8=E6=9C=AA?= =?UTF-8?q?=E6=8A=9B=E5=87=BA=E8=BF=9D=E4=BE=8B=E7=9A=84bug=20=20=202?= =?UTF-8?q?=EF=BC=89=E5=A2=9E=E5=8A=A0=E5=8F=8D=E5=B0=84=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=80=BC=E7=9A=84=E6=96=B9=E6=B3=95,?= =?UTF-8?q?=E4=BE=BF=E4=BA=8E=E8=84=9A=E6=9C=AC=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rule/core/code/java/template/impl/lib.tpl | 3 ++ .../java/io/sc/platform/util/ReflectUtil.java | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/code/java/template/impl/lib.tpl b/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/code/java/template/impl/lib.tpl index 91319892..f9e13db4 100644 --- a/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/code/java/template/impl/lib.tpl +++ b/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/code/java/template/impl/lib.tpl @@ -129,6 +129,9 @@ public class #(className(lib.code,lib.version)) { @JsonIgnoreProperties(ignoreUnknown=true) static class Argument { #(tabs(IndicatorGenerator.generateFields(lib.indicators),2)) + + Argument() throws Exception {} + public static Argument convertArgument(Map map) throws Exception { if(map!=null){ Argument arg =new Argument(); diff --git a/io.sc.platform.util/src/main/java/io/sc/platform/util/ReflectUtil.java b/io.sc.platform.util/src/main/java/io/sc/platform/util/ReflectUtil.java index 199fb12f..740c9876 100644 --- a/io.sc.platform.util/src/main/java/io/sc/platform/util/ReflectUtil.java +++ b/io.sc.platform.util/src/main/java/io/sc/platform/util/ReflectUtil.java @@ -2,6 +2,7 @@ package io.sc.platform.util; import org.springframework.util.StringUtils; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -134,4 +135,32 @@ public class ReflectUtil { Method method =clazz.getDeclaredMethod(methodName, innerParameterTypes); return (T)method.invoke(clazz, parameters); } + + public static Object getFieldValue(Object target, String fieldName) throws IllegalAccessException { + if(target==null) { return null; } + if(!StringUtils.hasText(fieldName)) { return null; } + Field field =null; + try{ + field =target.getClass().getDeclaredField(fieldName); + } catch (NoSuchFieldException e) { + return null; + } + if(field==null) { return null; } + field.setAccessible(true); + return field.get(target); + } + + public static void setFieldValue(Object target, String fieldName,Object value) throws IllegalAccessException { + if(target==null) { return; } + if(!StringUtils.hasText(fieldName)) { return; } + Field field =null; + try{ + field =target.getClass().getDeclaredField(fieldName); + } catch (NoSuchFieldException e) { + return; + } + if(field==null) { return; } + field.setAccessible(true); + field.set(target,value); + } }