From 388f625723cb11ec4bf0ca08b1a333a02e75142d Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Fri, 20 Sep 2024 18:17:45 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E8=BE=93=E5=85=A5=E5=AD=90=E8=A1=A8=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=AF=86=E7=A0=81=E6=8E=A7=E4=BB=B6=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1250058966630400]后端-表格输入子表新增密码控件类型 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1250058966630400 --- .../IFormAttributeDataConversionHandler.java | 10 ++++ .../attribute/handler/PasswordHandler.java | 19 +++++--- .../handler/TableInputerHandler.java | 47 +++++++++++++++++++ 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java b/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java index 016b47821..fbda551ea 100644 --- a/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java +++ b/src/main/java/neatlogic/framework/form/attribute/core/IFormAttributeDataConversionHandler.java @@ -114,4 +114,14 @@ public interface IFormAttributeDataConversionHandler { return 1; } + /** + * 密码加密 + * @param source 属性原始数据 + * @param configObj 属性配置信息 + * @return 返回加密后的数据 + */ + default Object passwordEncryption(Object source, JSONObject configObj) { + return source; + } + } diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/PasswordHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/PasswordHandler.java index bee2eff89..b445d40e5 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/PasswordHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/PasswordHandler.java @@ -51,13 +51,7 @@ public class PasswordHandler extends FormHandlerBase { @Override public Object conversionDataType(Object source, String attributeLabel) { - if (source == null) { - return null; - } - if (source instanceof String) { - return RC4Util.encrypt((String) source); - } - throw new AttributeValidException(attributeLabel); + return convertToString(source, attributeLabel); } @Override @@ -157,4 +151,15 @@ public class PasswordHandler extends FormHandlerBase { public Object dataTransformationForExcel(AttributeDataVo attributeDataVo, JSONObject configObj) { return attributeDataVo.getDataObj(); } + + @Override + public Object passwordEncryption(Object source, JSONObject configObj) { + if (source == null) { + return null; + } + if (source instanceof String) { + return RC4Util.encrypt((String) source); + } + return source; + } } diff --git a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java index 45d2e5458..f5eff8e91 100644 --- a/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java +++ b/src/main/java/neatlogic/module/framework/form/attribute/handler/TableInputerHandler.java @@ -18,6 +18,7 @@ package neatlogic.module.framework.form.attribute.handler; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.common.constvalue.ParamType; +import neatlogic.framework.common.util.RC4Util; import neatlogic.framework.form.attribute.core.*; import neatlogic.framework.form.constvalue.FormConditionModel; import neatlogic.framework.form.constvalue.FormHandler; @@ -851,4 +852,50 @@ public class TableInputerHandler extends FormHandlerBase { } } } + + @Override + public Object passwordEncryption(Object source, JSONObject configObj) { + JSONArray dataArray = null; + if (source instanceof JSONArray) { + dataArray = (JSONArray) source; + } + if (CollectionUtils.isEmpty(dataArray)) { + return source; + } + JSONArray dataConfig = configObj.getJSONArray("dataConfig"); + if (CollectionUtils.isNotEmpty(dataConfig)) { + for (int i = 0; i < dataConfig.size(); i++) { + JSONObject attr = dataConfig.getJSONObject(i); + String handler = attr.getString("handler"); + if (Objects.equals(handler, FormHandler.FORMPASSWORD.getHandler())) { + String uuid = attr.getString("uuid"); + for (int j = 0; j < dataArray.size(); j++) { + JSONObject dataObj = dataArray.getJSONObject(j); + if (MapUtils.isNotEmpty(dataObj)) { + String data = dataObj.getString(uuid); + if (StringUtils.isNotBlank(data)) { + dataObj.put(uuid, RC4Util.encrypt(data)); + } + } + } + } else if (Objects.equals(handler, "formtable")) { + JSONObject config = attr.getJSONObject("config"); + if (MapUtils.isEmpty(config)) { + continue; + } + String uuid = attr.getString("uuid"); + for (int j = 0; j < dataArray.size(); j++) { + JSONObject dataObj = dataArray.getJSONObject(j); + if (MapUtils.isNotEmpty(dataObj)) { + JSONArray data = dataObj.getJSONArray(uuid); + if (CollectionUtils.isNotEmpty(data)) { + this.passwordEncryption(data, config); + } + } + } + } + } + } + return dataArray; + } } -- Gitee