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