From 27e80a8f71dd88cb6491324b658c6c8f4cabae4a Mon Sep 17 00:00:00 2001 From: zhenggm Date: Tue, 30 Aug 2022 17:11:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=BC=95=E6=93=8E-=E6=96=B0?= =?UTF-8?q?=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/bpm/web/design/flow/ModelProc.java | 2 +- .../bpm/web/design/form/ModelFormDelHandler.java | 3 ++- .../listcard/single/FlowSingleLoadHandler.java | 2 +- .../listcard/single/FlowSingleSaveHandler.java | 6 ++++- .../flow/listcard/single/FlowSingleService.java | 5 ++-- .../smtweb/system/bpm/web/login/LoginHelper.java | 2 +- .../smtweb/framework/core/session/UserSession.java | 4 ++-- .../cc/smtweb/framework/core/util/JsonUtil.java | 28 ++++++++++++++++++++++ 8 files changed, 43 insertions(+), 9 deletions(-) diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProc.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProc.java index e6c1957..a6f306d 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProc.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProc.java @@ -25,7 +25,7 @@ public class ModelProc extends DefaultEntity { if (procInfo == null) { synchronized ("ModelProc_" + getId()) { if (procInfo == null) { - procInfo = JsonUtil.parse(getContent(), ProcInfo.class); + procInfo = JsonUtil.parse(getContent(), "model", ProcInfo.class); } } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormDelHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormDelHandler.java index 0311c6e..da6c038 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormDelHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormDelHandler.java @@ -28,7 +28,8 @@ public class ModelFormDelHandler extends DefaultDelHandler { @Override protected void delDb() { EntityDao dao = DbEngine.getInstance().findDao(ModelForm.class); - Set list = new HashSet<>(ModelFormCache.getInstance().getListByModule(id)); + Set l1 = ModelFormCache.getInstance().getListByModule(id); + Set list = l1 != null ? new HashSet<>(l1) : null; if (CommUtil.isEmpty(list)) { listDeled = null; dao.deleteEntity(id); diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java index 22f71a5..589e7b7 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java @@ -25,7 +25,7 @@ import java.util.ArrayList; /** * Created by Akmm at 2022-08-26 17:15 */ -public class FlowSingleLoadHandler extends LCSingleLoadHandler implements FlowListener { +public class FlowSingleLoadHandler extends LCSingleLoadHandler implements FlowListener { protected FlowInstance flowInstance; @Override diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java index 6e20353..74a9b8c 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java @@ -1,5 +1,6 @@ package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single; +import cc.smtweb.framework.core.common.R; import cc.smtweb.framework.core.db.impl.DefaultEntity; import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; @@ -8,5 +9,8 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler * 带流程的简单卡片之保存 */ public class FlowSingleSaveHandler extends LCSingleSaveHandler { - + @Override + public R save() { + return super.save(); + } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java index cde6607..b3775d1 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java @@ -1,6 +1,7 @@ package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single; import cc.smtweb.framework.core.annotation.SwService; +import cc.smtweb.framework.core.db.impl.DefaultEntity; import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleDelHandler; import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleLoadHandler; import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; @@ -14,12 +15,12 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; public class FlowSingleService extends LCSingleService { @Override protected LCSingleSaveHandler getSaveHandler() { - return super.getSaveHandler(); + return new FlowSingleSaveHandler(); } @Override protected LCSingleLoadHandler getLoadHandler() { - return super.getLoadHandler(); + return new FlowSingleLoadHandler(); } @Override diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/LoginHelper.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/LoginHelper.java index 9f69494..c3bdf0c 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/LoginHelper.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/login/LoginHelper.java @@ -32,7 +32,7 @@ public class LoginHelper { } if ("admin".equals(loginPO.getUsername())) { - return new UserSession(1); + return UserSession.createSys(); } if (StringUtils.isBlank(loginPO.getPassword())) { diff --git a/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/session/UserSession.java b/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/session/UserSession.java index 45efb91..37fb8d2 100644 --- a/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/session/UserSession.java +++ b/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/session/UserSession.java @@ -71,8 +71,8 @@ public class UserSession implements Serializable { public static UserSession createSys() { UserSession us = new UserSession(); - us.userId = 1; - us.partyId = 1; + us.userId = 1L; + us.partyId = 1L; us.terminalType = 0; return us; } diff --git a/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/util/JsonUtil.java b/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/util/JsonUtil.java index df9c493..74c5d6f 100644 --- a/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/util/JsonUtil.java +++ b/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/util/JsonUtil.java @@ -4,7 +4,9 @@ import cc.smtweb.framework.core.common.SwMap; import cc.smtweb.framework.core.exception.JsonParseException; import cc.smtweb.framework.core.util.jackson.*; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JavaType; @@ -101,6 +103,7 @@ public class JsonUtil { public static T parse(String str, Class clazz) { try { + if (StringUtils.isBlank(str)) { return null; } else { @@ -112,6 +115,31 @@ public class JsonUtil { } /** + * 解析指定json节点 + * @param str 完整json串 + * @param nodePath 待解析节点路径,如a.b.c + * @param clazz + * @return + * @param + */ + public static T parse(String str, String nodePath, Class clazz) { + try { + if (StringUtils.isBlank(str)) { + return null; + } + JsonNode node = OBJECT_MAPPER.readTree(str); + String[] nodes = nodePath.split("\\."); + for (String s: nodes) { + node = node.get(s); + if (node == null) return null; + } + return OBJECT_MAPPER.treeToValue(node, clazz); + } catch (Exception e) { + throw new JsonParseException("can't convert this json to " + clazz + " type", e); + } + } + + /** * 将Map对象转换为Bean对象 * * @param map Map对象