From 0c72e7e254175ff5147d4a1f1b7c6c46ff940db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=90=A6=E6=B6=9B?= Date: Fri, 10 Mar 2023 15:20:34 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90fix=20sonar=E3=80=91OSSFileController?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jero/modules/system/rule/OrgCodeRule.java | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/rule/OrgCodeRule.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/rule/OrgCodeRule.java index b233363d..aa2cccc6 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/rule/OrgCodeRule.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/rule/OrgCodeRule.java @@ -8,6 +8,7 @@ import com.jero.common.util.YouBianCodeUtil; import com.jero.modules.system.entity.SysDepart; import com.jero.modules.system.service.ISysDepartService; import io.netty.util.internal.StringUtil; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -34,16 +35,7 @@ public class OrgCodeRule implements IFillRuleHandler { // 定义旧编码字符串 String oldOrgCode = ""; - String parentId = null; - if (formData != null && formData.size() > 0) { - Object obj = formData.get("parentId"); - if (obj != null) parentId = obj.toString(); - } else { - if (params != null) { - Object obj = params.get("parentId"); - if (obj != null) parentId = obj.toString(); - } - } + String parentId = getParentId(params, formData); //如果是最高级,则查询出同级的org_code, 调用工具类生成编码并返回 if (StringUtil.isNullOrEmpty(parentId)) { @@ -90,4 +82,23 @@ public class OrgCodeRule implements IFillRuleHandler { strArray[1] = orgType; return strArray; } + + @Nullable + private String getParentId(JSONObject params, JSONObject formData) { + String parentId = null; + if (formData != null && formData.size() > 0) { + Object obj = formData.get("parentId"); + if (obj != null) { + parentId = obj.toString(); + } + } else { + if (params != null) { + Object obj = params.get("parentId"); + if (obj != null) { + parentId = obj.toString(); + } + } + } + return parentId; + } }