Bläddra i källkod

修正:js代码生成

master
郑根木 2 år sedan
förälder
incheckning
f4206fe9c3
3 ändrade filer med 18 tillägg och 19 borttagningar
  1. +12
    -13
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java
  2. +4
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  3. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java

+ 12
- 13
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java Visa fil

@@ -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<String, String> 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");
}
}

+ 4
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java Visa fil

@@ -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 "";
}


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java Visa fil

@@ -85,8 +85,8 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> {
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;


Laddar…
Avbryt
Spara