Przeglądaj źródła

增加:LC_SINGLE模型

4.0
郑根木 2 lat temu
rodzic
commit
705a80692a
12 zmienionych plików z 101 dodań i 120 usunięć
  1. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormCache.java
  2. +54
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormDelHandler.java
  3. +10
    -5
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java
  4. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormService.java
  5. +13
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/BaseModelWorker.java
  6. +4
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcSinlgeWorker.java
  7. +5
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java
  8. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java
  9. +1
    -1
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/EntityDao.java
  10. +0
    -1
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultDelHandler.java
  11. +1
    -0
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java
  12. +10
    -109
      smtweb-framework/core/src/main/resources/demo.json

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormCache.java Wyświetl plik

@@ -84,7 +84,7 @@ public class ModelFormCache extends AbstractEntityCache<ModelForm> {

//根据模块id,找对应的页面设计
public Set<ModelForm> getListByModule(long parent) {
return getListByKey(mt, String.valueOf(parent));
return getListByKey(ms, String.valueOf(parent));
}

public String getText(long id) {


+ 54
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormDelHandler.java Wyświetl plik

@@ -0,0 +1,54 @@
package cc.smtweb.system.bpm.web.design.form;

import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.mvc.service.DefaultDelHandler;
import cc.smtweb.framework.core.util.CommUtil;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* Created by Akmm at 2022-08-15 15:00
*/
public class ModelFormDelHandler extends DefaultDelHandler<ModelForm> {
//被删除的id
private Set<ModelForm> listDeled = new HashSet<>();
public ModelFormDelHandler() {
super(ModelForm.ENTITY_NAME);
}

@Override
protected void checkValid() {
// super.checkValid();
}

@Override
protected void delDb() {
EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(ModelForm.class);
listDeled = ModelFormCache.getInstance().getListByModule(id);
if (CommUtil.isEmpty(listDeled)) {
dao.deleteEntity(id);
} else {
List<Long> ids = new ArrayList<>();
ids.add(id);
for (ModelForm form: listDeled) {
ids.add(form.getId());
}
dao.deleteEntity(ids);
}
}

@Override
protected void saveSuccess() {
ModelFormCache cache = ModelFormCache.getInstance();
if (!CommUtil.isEmpty(listDeled)) {
for (ModelForm form: listDeled) {
cache.remove(form.getId());
}
}
cache.remove(id);
}
}

+ 10
- 5
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java Wyświetl plik

@@ -41,11 +41,16 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {

@Override
protected void insertBean(EntityDao<ModelForm> dao) {
super.insertBean(dao);
listFormChild = new ArrayList<>();
ModelFactory.getInstance().saveForm(bean, listFormChild);
super.insertBean(dao);
}

@Override
protected void checkValid() {
super.checkValid();
DbEngine.getInstance().findDao(ModelForm.class).checkUnique(bean, "mf_prj_id", "mf_name");
}

@Override
protected void saveSuccess() {
@@ -132,15 +137,15 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
}

public R saveModelByTmpl() {
long id = params.readLong("pageId");
String templateId = params.readString("templateId");
String id = params.readString("pageId");
String data = params.readString("data");
bean = loadComp(id);
bean = ModelFormHelper.getFromCache(id);
if (StringUtils.isEmpty(data)) {
throw new BizException("没有待保存的数据!");
}
bean.setTmpl(data);
ModelFormHelper.buildSaveModelByTmpl(bean, templateId);
ModelFactory.getInstance().buildSaveModel(bean);
// ModelFormHelper.buildSaveModelByTmpl(bean, templateId);
DbEngine.getInstance().doTrans(new AbsDbWorker() {
@Override
public void work() {


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormService.java Wyświetl plik

@@ -36,7 +36,7 @@ public class ModelFormService extends AbstractCompService {
case TYPE_SAVE:
return new ModelFormSaveHandler();
case TYPE_DEL:
return new DefaultDelHandler<ModelForm>(ModelForm.ENTITY_NAME);
return new ModelFormDelHandler();
case TYPE_LIST:
return new DefaultListHandler<ModelForm>(ModelForm.ENTITY_NAME);
case TYPE_CODE:


+ 13
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/BaseModelWorker.java Wyświetl plik

@@ -18,6 +18,11 @@ import java.util.Set;
* 抽象类的页面保存,供各模板继承使用
*/
public class BaseModelWorker {
/**
* 模块/页面保存:opts根据模型做些个性化处理,如果是模块,需要添加子页面
* @param bean
* @param listFormChild
*/
public void saveForm(ModelForm bean, List<ModelForm> listFormChild) {
SwMap opts = bean.getOpts();
if (opts != null) {
@@ -62,4 +67,12 @@ public class BaseModelWorker {

return page;
}

/**
* 根据模型生成页面
* @param bean
*/
public void buildSaveModel(ModelForm bean) {

}
}

+ 4
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/LcSinlgeWorker.java Wyświetl plik

@@ -5,6 +5,7 @@ import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
import cc.smtweb.system.bpm.web.design.form.ModelFormCache;
@@ -27,8 +28,9 @@ public class LcSinlgeWorker extends BaseModelWorker {
SwMap cfgPage = new SwMap();
cfg.put(ModelFormHelper.OPT_PAGE, cfgPage);
String formName = ModelFormHelper.getPageName(bean) + StringUtil.upFirst(SwEnum.PageType.LIST.value);
cfg.put(SwEnum.PageType.LIST.value, formName);

cfgPage.put(SwEnum.PageType.LIST.value, formName);
bean.setOption(JsonUtil.encodeString(opts));
ModelForm page;
if (bean.isNew()) {//新增
page = createPage(bean, SwEnum.PageType.LIST.value);


+ 5
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java Wyświetl plik

@@ -41,4 +41,9 @@ public class ModelFactory {
BaseModelWorker worker = getWorker(bean);
worker.saveForm(bean, listFormChild);
}

public void buildSaveModel(ModelForm bean) {
BaseModelWorker worker = getWorker(bean);
worker.buildSaveModel(bean);
}
}

+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java Wyświetl plik

@@ -165,6 +165,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
}
//暂时不考虑list保存的情况
bean.getData().putAll(data);
bean.setIsNew(false);
}

return bean;


+ 1
- 1
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/EntityDao.java Wyświetl plik

@@ -363,7 +363,7 @@ public class EntityDao<T> extends AbstractEntityDao<T> {
args.add(readValue(bean, f));
sTitle += "+" + modelTable.findFieldTitle(f);
}
if (jdbcEngine.isExists("select 1 from " + modelTable.getSchemaTableName() + " where " + modelTable.getIdField() + "=? " + ss, args.toArray()))
if (jdbcEngine.isExists("select 1 from " + modelTable.getSchemaTableName() + " where " + modelTable.getIdField() + " <> ? " + ss, args.toArray()))
throw new BizException(sTitle.substring(1) + " 不能重复!");
}
}

+ 0
- 1
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultDelHandler.java Wyświetl plik

@@ -24,7 +24,6 @@ public class DefaultDelHandler<T extends DefaultEntity> extends AbstractDelHandl
protected void checkValid() {
EntityHelper.checkExists(tableName, id);
// ModelTable table = ModelTableCache.getInstance().getByName(tableName);
//todo 检查外键引用的使用情况

}



+ 1
- 0
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java Wyświetl plik

@@ -62,6 +62,7 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan
@Override
protected void readFromPage() {
bean.readFromMap(params);
bean.setIsNew(isNew);
}

@Override


+ 10
- 109
smtweb-framework/core/src/main/resources/demo.json Wyświetl plik

@@ -1,112 +1,13 @@
{
"fields": [
{
"locked": 1,
"name": "bp_id",
"title": "主键",
"fieldType": 1,
"dataType": "id",
"null": 1,
"default": -1
},
{
"name": "bp_number",
"editor": "num",
"title": "第几届",
"remark": "第几届",
"dataType": "int",
"default": "",
"null": 1
},
{
"name": "bp_name",
"editor": "input",
"title": "届别名称",
"dataType": "name",
"default": "",
"remark": "根据第几届自动生成",
"null": 1
},
{
"name": "bp_start_time",
"editor": "datetime",
"title": "届别开始时间",
"dataType": "datetime",
"default": "0",
"remark": "届别开始时间",
"null": 1
},
{
"name": "bp_end_time",
"editor": "datetime",
"title": "届别结束时间",
"dataType": "datetime",
"default": "0",
"remark": "届别结束时间",
"null": 1
},
{
"name": "bp_create_uid",
"editor": "input",
"title": "创建人",
"fieldType": 7,
"dataType": "id",
"default": "",
"remark": "创建人",
"null": 1
},
{
"name": "bp_create_time",
"editor": "datetime",
"title": "创建时间",
"fieldType": 8,
"dataType": "datetime",
"default": "",
"remark": "创建时间",
"null": 1
},
{
"name": "bp_update_uid",
"editor": "input",
"title": "更新人",
"fieldType": 9,
"dataType": "id",
"default": "",
"remark": "更新人",
"null": 1
},
{
"name": "bp_update_time",
"editor": "datetime",
"title": "更新时间",
"fieldType": 10,
"dataType": "datetime",
"default": "",
"remark": "更新时间",
"null": 1
},
{
"name": "bp_state",
"editor": "combo",
"title": "状态",
"dataType": "bool",
"default": "0",
"remark": "1启用0无效",
"null": 1
}
],
"indexes": [
{
"locked": 1,
"fields": "bp_id",
"type": "P"
}
],
"caches": [
{
"name": "n",
"fields": "bp_name",
"type": "M"
"config": {
"model": "LC_SINGLE",
"props": {
"masterTable": "2",
"masterTable_text": "目录定义"
},
"page": {
"list": "bpm.sTestMList"
}
]
},
"pageType": "list"
}

Ładowanie…
Anuluj
Zapisz