From f4206fe9c325b8f5bb9017e447e32a04db29bf0b Mon Sep 17 00:00:00 2001 From: zhenggm Date: Mon, 11 Jul 2022 18:34:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9Ajs=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/web/design/form/CodeBuildHandler.java | 25 +++++++++++----------- .../bpm/web/design/form/ModelFormHelper.java | 8 +++---- .../bpm/web/design/form/ModelFormLoadHandler.java | 4 ++-- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java index 8246631..2b443a0 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java @@ -6,7 +6,6 @@ import cc.smtweb.framework.core.db.vo.ModelCache; import cc.smtweb.framework.core.db.vo.ModelField; import cc.smtweb.framework.core.db.vo.ModelTable; import cc.smtweb.framework.core.exception.BizException; -import cc.smtweb.framework.core.exception.SwException; import cc.smtweb.framework.core.mvc.service.AbstractHandler; import cc.smtweb.framework.core.util.DateUtil; import cc.smtweb.framework.core.util.MapUtil; @@ -34,7 +33,7 @@ public class CodeBuildHandler extends AbstractHandler { private String userName; //java文件所在路径 - private String codeJavaPath; + private String codePath; private String packageName; private BpmConfigBean bpmConfigBean; @@ -68,15 +67,15 @@ public class CodeBuildHandler extends AbstractHandler { if (StringUtils.isEmpty(moduleName)) throw new BizException("此项目未定义Module!"); final String eventPath = ModelFormHelper.getEventPath(form); - codeJavaPath = ModelFormHelper.getCodePath(form) + "/" + eventPath.replaceAll("\\.", "/"); - new File(codeJavaPath).mkdirs(); + codePath = ModelFormHelper.getCodePath(form) + "/src/main/resources/static/" + moduleName + "/" + eventPath.replaceAll("\\.", "/"); + new File(codePath).mkdirs(); SwMap model = new SwMap(); model.put("user", userName); model.put("sysTime", DateUtil.nowDateTime()); model.put("title", form.getTitle()); model.put("eventPath", eventPath + "." + form.getName()); - CodeGenerator.getInstance().generateJsEvent(model, codeJavaPath + "/" + form.getName() + ".js"); + CodeGenerator.getInstance().generateJsEvent(model, codePath + "/" + form.getName() + ".js"); return R.success(); } @@ -99,18 +98,18 @@ public class CodeBuildHandler extends AbstractHandler { BpmConfigBean bpmConfigBean = SpringUtil.getBean(BpmConfigBean.class); Map mapIdeaModules = IdeaUtil.getModules(bpmConfigBean.getCodeJavaPath()); if (mapIdeaModules == null || mapIdeaModules.isEmpty()) throw new BizException("没有定义idea项目的路径(smtweb.bpm.codeJavaPath)!"); - codeJavaPath = mapIdeaModules.get(moduleName); - if (StringUtils.isEmpty(codeJavaPath)) { + codePath = mapIdeaModules.get(moduleName); + if (StringUtils.isEmpty(codePath)) { throw new BizException("没有找到对应项目在idea中Module的路径(" + moduleName + ")!"); } - codeJavaPath += "/src/main/java/"; + codePath += "/src/main/java/"; //加上目录 String cn = ModelCatalogCache.getInstance().getFullName(form.getMcId()); if (StringUtils.isNotEmpty(cn)) { packageName += "." + cn; } - codeJavaPath += packageName.replaceAll("\\.", "/"); - new File(codeJavaPath).mkdirs(); + codePath += packageName.replaceAll("\\.", "/"); + new File(codePath).mkdirs(); } /** @@ -144,7 +143,7 @@ public class CodeBuildHandler extends AbstractHandler { fn.put("shortJavaType", dtb.shortJavaType); } - CodeGenerator.getInstance().generateBean(model, codeJavaPath + "/" + beanName + ".java"); + CodeGenerator.getInstance().generateBean(model, codePath + "/" + beanName + ".java"); } if (needCache) { @@ -161,7 +160,7 @@ public class CodeBuildHandler extends AbstractHandler { fn.put("fields", cache.getFields()); } - CodeGenerator.getInstance().generateCache(model, codeJavaPath + "/" + beanName + "Cache.java"); + CodeGenerator.getInstance().generateCache(model, codePath + "/" + beanName + "Cache.java"); } } @@ -179,6 +178,6 @@ public class CodeBuildHandler extends AbstractHandler { model.put("service", sName); model.put("eventPath", ModelFormHelper.getEventPath(form)); - CodeGenerator.getInstance().generateService(model, codeJavaPath + "/" + sName + "Service.java"); + CodeGenerator.getInstance().generateService(model, codePath + "/" + sName + "Service.java"); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java index d92acb6..19e4e10 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java @@ -383,10 +383,10 @@ public class ModelFormHelper { public static String getEventPath(ModelForm bean) { String moduleName = ModelProjectCache.getInstance().getModule(bean.getPrjId()); if (StringUtils.isNotEmpty(moduleName)) { - String ep = moduleName; - String cn = ModelCatalogCache.getInstance().getFullName(bean.getMcId()); - if (StringUtils.isNotEmpty(cn)) ep = ep + "." + cn; - return ep; +// String ep = moduleName; + return ModelCatalogCache.getInstance().getFullName(bean.getMcId()); +// if (StringUtils.isNotEmpty(cn)) ep = ep + "." + cn; +// return ep; } return ""; } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java index 90db027..fd6da5c 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java @@ -85,8 +85,8 @@ public class ModelFormLoadHandler extends DefaultLoadHandler { if (StringUtils.isEmpty(codeJavaPath)) { return r; } - - String path = codeJavaPath + "/" + ModelFormHelper.getEventPath(form).replaceAll("\\.", "/") + "/" + form.getName() + ".js"; + String moduleName = ModelProjectCache.getInstance().getModule(form.getPrjId()); + String path = ModelFormHelper.getCodePath(form) + "/src/main/resources/static/" + moduleName + "/" + ModelFormHelper.getEventPath(form).replaceAll("\\.", "/") + "/" + form.getName() + ".js"; String js = FileUtil.readFileStr(path); if (StringUtils.isEmpty(js)) { return r;