Sfoglia il codice sorgente

删多余module,加js模板

master
郑根木 2 anni fa
parent
commit
1f73e90aaf
5 ha cambiato i file con 69 aggiunte e 4 eliminazioni
  1. +0
    -3
      smtweb-framework/pom.xml
  2. +6
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/util/CodeGenerator.java
  3. +35
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java
  4. +11
    -1
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormService.java
  5. +17
    -0
      smtweb-system/sw-system-bpm/src/main/resources/static/template/js_event.ftl

+ 0
- 3
smtweb-framework/pom.xml Vedi File

@@ -26,9 +26,6 @@

<modules>
<module>sw-framework-core</module>
<module>sw-framework-auth</module>
<module>sw-framework-file</module>
<module>sw-framework-web</module>
<module>../smtweb-system/sw-system-bpm</module>
</modules>
</project>

+ 6
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/util/CodeGenerator.java Vedi File

@@ -24,6 +24,7 @@ public class CodeGenerator {
private final static String TEMPLATE_JAVA_BEAN = "java_bean";
private final static String TEMPLATE_JAVA_CACHE = "java_cache";
private final static String TEMPLATE_JAVA_SERVICE = "java_service";
private final static String TEMPLATE_JS_EVENT = "js_event";
private static CodeGenerator instance = null;

private Configuration configuration = null;
@@ -111,6 +112,11 @@ public class CodeGenerator {
generate(model, TEMPLATE_JAVA_SERVICE, fileName);
}

public void generateJsEvent(Map<String, Object> model, String fileName) {
generate(model, TEMPLATE_JS_EVENT, fileName);
}


/**
* 获取单实例
*


+ 35
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java Vedi File

@@ -58,6 +58,35 @@ public class CodeBuildHandler extends AbstractHandler {
return R.success();
}

public R buildJsCode() {
userName = String.valueOf(us.getUserId());
//页面id
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());

if (StringUtils.isEmpty(moduleName) || SwConsts.DEF_DB_NAME.equals(moduleName) || moduleName.equals("bpm")) {
moduleName = "sw-system-bpm";
}
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)) {
throw new BizException("没有找到对应项目在idea中Module的路径(" + moduleName + ")!");
}
codeJavaPath += "/src/main/resources/";
//加上目录
String cn = ModelCatalogCache.getInstance().getFullName(form.getMcId());
if (StringUtils.isNotEmpty(cn)) {
codeJavaPath += cn.replaceAll("\\.", "/");
}
new File(codeJavaPath).mkdirs();

return R.success();
}

/**
* 构建java代码路径
*
@@ -89,6 +118,12 @@ public class CodeBuildHandler extends AbstractHandler {
}
codeJavaPath += packageName.replaceAll("\\.", "/");
new File(codeJavaPath).mkdirs();

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

/**


+ 11
- 1
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormService.java Vedi File

@@ -145,7 +145,7 @@ public class ModelFormService extends AbstractCompService {
return R.success(CodeGenerator.getInstance().getModelTemplates());
}

//加载模板定义
//生成java代码
public R buildJavaCode(@SwBody SwMap params, UserSession us) {
try {
CodeBuildHandler handler = (CodeBuildHandler) getHandler(params, us, TYPE_CODE);
@@ -154,4 +154,14 @@ public class ModelFormService extends AbstractCompService {
return R.error("操作失败!", e);
}
}

//生成js代码
public R buildJsCode(@SwBody SwMap params, UserSession us) {
try {
CodeBuildHandler handler = (CodeBuildHandler) getHandler(params, us, TYPE_CODE);
return handler.buildJsCode();
} catch (Exception e) {
return R.error("操作失败!", e);
}
}
}

+ 17
- 0
smtweb-system/sw-system-bpm/src/main/resources/static/template/js_event.ftl Vedi File

@@ -0,0 +1,17 @@
/**
* Created by ${user} at ${sysTime}
* 注册事件类【${title}】,参看event.defaultEvent.js
*/
window.$swEvent.setup("defaultEvent", {
setup(page){
const { $params,$refs, $widgets, $model, $utils, $tabRouter, $api } = page;
const { $$message, $$http } = $utils;
// 示例
const demoFunc = () => {

};
return {
demoFunc,
}
}
});

Caricamento…
Annulla
Salva