Browse Source

修正:js代码生成

master
郑根木 2 years ago
parent
commit
741da786d0
4 changed files with 31 additions and 7 deletions
  1. +2
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHelper.java
  2. +3
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java
  3. +16
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  4. +10
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java

+ 2
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHelper.java View File

@@ -31,4 +31,6 @@ public class ModelCatalogTreeHelper extends TreeHelper<ModelCatalog> {
list.sort(comparator);
return list;
}


}

+ 3
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java View File

@@ -67,14 +67,15 @@ public class CodeBuildHandler extends AbstractHandler {
String moduleName = ModelProjectCache.getInstance().getModule(form.getPrjId());
if (StringUtils.isEmpty(moduleName)) throw new BizException("此项目未定义Module!");

codeJavaPath = ModelFormHelper.getEventPath(form);
final String eventPath = ModelFormHelper.getEventPath(form);
codeJavaPath = ModelFormHelper.getCodePath(form) + "/" + eventPath.replaceAll("\\.", "/");
new File(codeJavaPath).mkdirs();

SwMap model = new SwMap();
model.put("user", userName);
model.put("sysTime", DateUtil.nowDateTime());
model.put("title", form.getTitle());
model.put("eventPath", ModelFormHelper.getEventPath(form));
model.put("eventPath", eventPath + "." + form.getName());
CodeGenerator.getInstance().generateJsEvent(model, codeJavaPath + "/" + form.getName() + ".js");
return R.success();
}


+ 16
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java View File

@@ -362,17 +362,31 @@ public class ModelFormHelper {
public static void buildOptsEx(ModelForm bean, SwMap opts) {
String eventPath = getEventPath(bean);
if (StringUtils.isNotEmpty(eventPath)) {
opts.put(KEY_EVENT_PATH, eventPath);
opts.put(KEY_EVENT_PATH, eventPath + "." + bean.getName());
}
}

public static String getCodePath(ModelForm bean) {
String moduleName = ModelProjectCache.getInstance().getModule(bean.getPrjId());
if (StringUtils.isEmpty(moduleName)) return null;

BpmConfigBean bpmConfigBean = SpringUtil.getBean(BpmConfigBean.class);
Map<String, String> mapIdeaModules = IdeaUtil.getModules(bpmConfigBean.getCodeJavaPath());
if (mapIdeaModules.isEmpty()) throw new BizException("没有定义idea项目的路径(smtweb.bpm.codeJavaPath)!");
String codeJavaPath = mapIdeaModules.get(moduleName);
if (StringUtils.isEmpty(codeJavaPath)) {
throw new BizException("没有找到对应项目在idea中Module的路径(" + moduleName + ")!");
}
return codeJavaPath;
}

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 + "." + bean.getName();
return ep;
}
return "";
}


+ 10
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java View File

@@ -7,12 +7,16 @@ import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler;
import cc.smtweb.framework.core.util.FileUtil;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.framework.core.util.SpringUtil;
import cc.smtweb.system.bpm.spring.BpmConfigBean;
import cc.smtweb.system.bpm.util.IdeaUtil;
import cc.smtweb.system.bpm.web.design.db.ModelProjectCache;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2022/5/9 16:17
@@ -73,13 +77,16 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> {
long pageId = params.readLong("pageId");
ModelForm form = ModelFormCache.getInstance().get(pageId);
if (form == null) throw new BizException("未找到指定的页面定义(" + pageId + ")!");
String moduleName = ModelProjectCache.getInstance().getModule(form.getPrjId());
List<String> listRet = new ArrayList<>();
R r = R.success(listRet);
if (StringUtils.isEmpty(moduleName)) {

String codeJavaPath = ModelFormHelper.getCodePath(form);
if (StringUtils.isEmpty(codeJavaPath)) {
return r;
}
String path = ModelFormHelper.getEventPath(form) + "/" + form.getName() + ".js";

String path = codeJavaPath + "/" + ModelFormHelper.getEventPath(form).replaceAll("\\.", "/") + "/" + form.getName() + ".js";
String js = FileUtil.readFileStr(path);
if (StringUtils.isEmpty(js)) {
return r;


Loading…
Cancel
Save