Sfoglia il codice sorgente

js代码生成

master
郑根木 2 anni fa
parent
commit
89c89b73cc
11 ha cambiato i file con 88 aggiunte e 97 eliminazioni
  1. +1
    -0
      smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java
  2. +6
    -6
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/CodeBuildHandler.java
  3. +7
    -1
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/preview/PreviewMenuTreeService.java
  4. +23
    -9
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageLoadHandler.java
  5. +5
    -1
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java
  6. +1
    -1
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/area/AreaCache.java
  7. +35
    -0
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/area/AreaHandler.java
  8. +9
    -0
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/area/AreaService.java
  9. +0
    -45
      smtweb-framework/sw-system-bpm/src/main/resources/config/application-dev.yaml
  10. +0
    -33
      smtweb-framework/sw-system-bpm/src/main/resources/config/application-prod.yaml
  11. +1
    -1
      smtweb-framework/sw-system-bpm/src/main/resources/static/template/java_cache.ftl

+ 1
- 0
smtweb-framework/sw-framework-core/src/main/java/cc/smtweb/framework/core/common/SwEnum.java Vedi File

@@ -124,6 +124,7 @@ public interface SwEnum {
public static DataTypeBean NAME = instance.addEnum("name", "名称", "varchar", 100, "String", "Str", Types.VARCHAR, "", EditorType.INPUT.value);
public static DataTypeBean REMARK = instance.addEnum("remark", "备注", "varchar", 255, "String", "Str", Types.VARCHAR, "", EditorType.INPUT.value);
public static DataTypeBean TEXT = instance.addEnum("text", "大文本", "text", 0, "String", "Str", Types.CLOB, "", EditorType.TEXT.value);
public static DataTypeBean LONG = instance.addEnum("long", "长整型", "bigint", 0, "long", "Long", Types.BIGINT, "0", EditorType.INPUT.value);
public static DataTypeBean INT = instance.addEnum("int", "整型", "int", 0, "int", "Int", Types.INTEGER, "0", EditorType.NUMBER.value);
public static DataTypeBean SHORT = instance.addEnum("short", "短整型", "smallint", 0, "int", "Int", Types.SMALLINT, "0", EditorType.NUMBER.value);
public static DataTypeBean BOOL = instance.addEnum("bool", "布尔型", "tinyint", 0, "boolean", "Bool", Types.TINYINT, "0", EditorType.SWITCH.value);


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

@@ -84,6 +84,12 @@ public class CodeBuildHandler extends AbstractHandler {
}
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));
CodeGenerator.getInstance().generateJsEvent(model, codeJavaPath + "/" + form.getName() + ".js");
return R.success();
}

@@ -118,12 +124,6 @@ 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");
}

/**


+ 7
- 1
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/preview/PreviewMenuTreeService.java Vedi File

@@ -12,6 +12,7 @@ import cc.smtweb.system.bpm.util.TreeDataUtil;
import cc.smtweb.system.bpm.web.design.db.ModelProjectCache;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormCache;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;
@@ -23,7 +24,12 @@ public class PreviewMenuTreeService {

public R treeAll(@SwParam("module") String module, UserSession us) {
String prj_id = ModelProjectCache.getInstance().getIdByModule(module);
List<ModelForm> listForm = new ArrayList<>(ModelFormCache.getInstance().getFormsByPrj(Long.parseLong(prj_id)));
List<ModelForm> listForm;
if (StringUtils.isNotEmpty(prj_id)) {
listForm = new ArrayList<>(ModelFormCache.getInstance().getFormsByPrj(Long.parseLong(prj_id)));
} else {
listForm = new ArrayList<>(ModelFormCache.getInstance().getAll());
}
listForm.sort((o1, o2) -> CommUtil.chineseCompare(o1.getTitle(), o2.getTitle()));
if (listForm.isEmpty()) throw new BizException("此项目无页面设计!");



+ 23
- 9
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageLoadHandler.java Vedi File

@@ -34,31 +34,45 @@ public class DynPageLoadHandler extends AbstractDynPageHandler {
continue;
}
if (SwEnum.DatasetType.FORM.value.equals(dataSet.type)) {//单表
SwMap data;
//懒加载,给个空对象
if (dataSet.lazy) {
mapRet.put(dataSet.name, new SwMap());
continue;
data = new SwMap();
} else {
data = DynPageHelper.createBean(dataSet);
}
mapRet.put(dataSet.name, DynRetBean.createBean(DynPageHelper.createBean(dataSet)));
afterAddBean(dataSet, data);
mapRet.put(dataSet.name, DynRetBean.createBean(data));
} else if (SwEnum.DatasetType.TREE.value.equals(dataSet.type)) {//树
mapRet.put(dataSet.name, DynRetBean.createBean(new SwMap()));
SwMap data = new SwMap();
afterAddBean(dataSet, data);
mapRet.put(dataSet.name, DynRetBean.createBean(data));
} else if (!SwEnum.DatasetType.ENUM.value.equals(dataSet.type)) {//非枚举
mapRet.put(dataSet.name, DynRetBean.createList(SwListData.create(null, 0)));
SwListData listData = SwListData.create(null, 0);
afterAddList(dataSet, listData);
mapRet.put(dataSet.name, DynRetBean.createList(listData));
}
}
return R.success(mapRet);
}

//新增初始化 - bean
protected void afterAddBean(PageDataset dataset, SwMap bean){}
//新增初始化 - list
protected void afterAddList(PageDataset dataset, SwListData bean){}

//新增操作,初始化定义的数据集
public R addOne() {
//对应的数据集定义
PageDataset pageDataSet = readParamDs();
PageDataset dataset = readParamDs();

if (!pageDataSet.canEdit) {
return R.error("指定数据集为只读数据集[" + pageDataSet.label + "]!");
if (!dataset.canEdit) {
return R.error("指定数据集为只读数据集[" + dataset.label + "]!");
}
//懒加载,给个空对象
return R.success(DynRetBean.createBean(DynPageHelper.createBean(pageDataSet)));
SwMap data = DynPageHelper.createBean(dataset);
afterAddBean(dataset, data);
return R.success(DynRetBean.createBean(data));
}

public R loadOne() {


+ 5
- 1
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java Vedi File

@@ -34,6 +34,10 @@ import java.util.Map;
public class DynPageSaveHandler extends AbstractDynPageHandler {
private Map<String, List<DefaultEntity>> mapTreeBean = new HashMap<>();

protected void setNewId(DefaultEntity bean) {
bean.setEntityId(DbEngine.getInstance().nextId());
}

/**
* 保存指定数据集操作,入参:{pageId,dataset:"", data:{form:{},list: {total:0,rows:[]}}, filter:{}}
*/
@@ -152,7 +156,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
if (id <= 0) {
bean = dao.createBean();
bean.setIsNew(true);
bean.setEntityId(DbEngine.getInstance().nextId());
setNewId(bean);
} else {
bean = dao.queryEntity(id);
if (bean == null) {


+ 1
- 1
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/area/AreaCache.java Vedi File

@@ -13,7 +13,7 @@ import java.util.Set;
* Created by 1 at 2022-06-17 07:58:14
* 实体【[行政区划](SYS_AREA)】的缓存类
*/
@SwCache(ident = "SYS_AREA", title = "页面定义")
@SwCache(ident = "SYS_AREA", title = "行政区划")
public class AreaCache extends AbstractEntityCache<Area> {
//缓存key:按父ID
public final static String mk_pr = "pr";


+ 35
- 0
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/area/AreaHandler.java Vedi File

@@ -0,0 +1,35 @@
package cc.smtweb.system.bpm.web.sys.user.area;

import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageLoadHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageSaveHandler;

/**
* Created by Akmm at 2022/7/1 15:47
* 区划保存
*/
public class AreaHandler {
static class AreaSaveHandler extends DynPageSaveHandler {
@Override
protected void setNewId(DefaultEntity bean) {
if (bean instanceof Area) {
Area area = (Area) bean;
area.setEntityId(Long.parseLong(area.getCode()));
} else {
super.setNewId(bean);
}
}
}

static class AreaLoadHandler extends DynPageLoadHandler {
@Override
protected void afterAddBean(PageDataset dataset, SwMap bean) {
super.afterAddBean(dataset, bean);
Area area = new Area();
area.setData(bean);
// area.setSeq();
}
}
}

+ 9
- 0
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/area/AreaService.java Vedi File

@@ -4,6 +4,9 @@ import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageDelHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageLoadHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageSaveHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
@@ -17,6 +20,12 @@ public class AreaService extends DynPageService {
//public final static String TYPE_DEMO = "demo";
@Override
protected AbstractHandler createHandler(String type) {
switch (type) {
case TYPE_SAVE:
return new AreaHandler.AreaSaveHandler();
case TYPE_LOAD:
return new AreaHandler.AreaLoadHandler();
}
return super.createHandler(type);
}



+ 0
- 45
smtweb-framework/sw-system-bpm/src/main/resources/config/application-dev.yaml Vedi File

@@ -1,45 +0,0 @@
smtweb:
machine-id: 1
file:
local-path: /data/sw/files/
url: http://127.0.0.1:8888/sw/files/
bpm:
debug: true
code-java-path: '/code/2021/java/sw-sys-uc/sw-sys-uc-web/src/main/java/'
code-java-package: 'cc.smtweb.system.uc.web'
config-ui-path: '/code/2021/java/sw-sys-uc/sw-sys-uc-web/src/main/resources/plugin/config/'
db:
type: mysql
default:
rule:
prefix: _smt_
replace: smt_
server:
port: 8888
servlet:
context-path: /
logging:
level:
root: INFO
cc.smtweb: DEBUG
spring:
redis:
host: 127.0.0.1
port: 6379
password:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/smt_asp?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
username: root
password: root
servlet:
multipart:
max-file-size: 104857600000
max-request-size: 10485760000000
cache:
type: caffeine
cache-names:
- core
- bpm
caffeine:
spec: maximumSize=1024,expireAfterWrite=2h

+ 0
- 33
smtweb-framework/sw-system-bpm/src/main/resources/config/application-prod.yaml Vedi File

@@ -1,33 +0,0 @@
sme:
machine-id: 1
file-local-path: /data/files/smart/
file-host: http://bpm.smtweb.cc
file-url: ${sme.file-host}:${server.port}${server.servlet.context-path}/${sme.file-local-path}
server:
port: 10001
servlet:
context-path: /
logging:
level:
smtweb: DEBUG
spring:
main:
allow-bean-definition-overriding: true
mvc:
static-path-pattern: /static/**
redis:
host: 127.0.0.1
port: 6379
datasource:
user:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/smt_user?useUnicode=true&characterEncoding=utf-8&useTimezone=true&serverTimezone=CTT&allowMultiQueries=true
username: smt
password: smt_123456
servlet:
multipart:
max-file-size: 104857600000
max-request-size: 10485760000000




+ 1
- 1
smtweb-framework/sw-system-bpm/src/main/resources/static/template/java_cache.ftl Vedi File

@@ -13,7 +13,7 @@ import java.util.Set;
* Created by ${user} at ${sysTime}
* 实体【[${tableTitle}](${tableName})】的缓存类
*/
@SwCache(ident = "${tableName}", title = "页面定义")
@SwCache(ident = "${tableName}", title = "${tableTitle}")
public class ${beanName}Cache extends AbstractEntityCache<${beanName}> {
<#list caches as cache>
//缓存key:${cache.title}


Caricamento…
Annulla
Salva