@@ -84,7 +84,7 @@ public class ModelFormCache extends AbstractEntityCache<ModelForm> { | |||||
//根据模块id,找对应的页面设计 | //根据模块id,找对应的页面设计 | ||||
public Set<ModelForm> getListByModule(long parent) { | public Set<ModelForm> getListByModule(long parent) { | ||||
return getListByKey(mt, String.valueOf(parent)); | |||||
return getListByKey(ms, String.valueOf(parent)); | |||||
} | } | ||||
public String getText(long id) { | public String getText(long id) { | ||||
@@ -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); | |||||
} | |||||
} |
@@ -41,11 +41,16 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> { | |||||
@Override | @Override | ||||
protected void insertBean(EntityDao<ModelForm> dao) { | protected void insertBean(EntityDao<ModelForm> dao) { | ||||
super.insertBean(dao); | |||||
listFormChild = new ArrayList<>(); | listFormChild = new ArrayList<>(); | ||||
ModelFactory.getInstance().saveForm(bean, listFormChild); | 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 | @Override | ||||
protected void saveSuccess() { | protected void saveSuccess() { | ||||
@@ -132,15 +137,15 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> { | |||||
} | } | ||||
public R saveModelByTmpl() { | public R saveModelByTmpl() { | ||||
long id = params.readLong("pageId"); | |||||
String templateId = params.readString("templateId"); | |||||
String id = params.readString("pageId"); | |||||
String data = params.readString("data"); | String data = params.readString("data"); | ||||
bean = loadComp(id); | |||||
bean = ModelFormHelper.getFromCache(id); | |||||
if (StringUtils.isEmpty(data)) { | if (StringUtils.isEmpty(data)) { | ||||
throw new BizException("没有待保存的数据!"); | throw new BizException("没有待保存的数据!"); | ||||
} | } | ||||
bean.setTmpl(data); | bean.setTmpl(data); | ||||
ModelFormHelper.buildSaveModelByTmpl(bean, templateId); | |||||
ModelFactory.getInstance().buildSaveModel(bean); | |||||
// ModelFormHelper.buildSaveModelByTmpl(bean, templateId); | |||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | DbEngine.getInstance().doTrans(new AbsDbWorker() { | ||||
@Override | @Override | ||||
public void work() { | public void work() { | ||||
@@ -36,7 +36,7 @@ public class ModelFormService extends AbstractCompService { | |||||
case TYPE_SAVE: | case TYPE_SAVE: | ||||
return new ModelFormSaveHandler(); | return new ModelFormSaveHandler(); | ||||
case TYPE_DEL: | case TYPE_DEL: | ||||
return new DefaultDelHandler<ModelForm>(ModelForm.ENTITY_NAME); | |||||
return new ModelFormDelHandler(); | |||||
case TYPE_LIST: | case TYPE_LIST: | ||||
return new DefaultListHandler<ModelForm>(ModelForm.ENTITY_NAME); | return new DefaultListHandler<ModelForm>(ModelForm.ENTITY_NAME); | ||||
case TYPE_CODE: | case TYPE_CODE: | ||||
@@ -18,6 +18,11 @@ import java.util.Set; | |||||
* 抽象类的页面保存,供各模板继承使用 | * 抽象类的页面保存,供各模板继承使用 | ||||
*/ | */ | ||||
public class BaseModelWorker { | public class BaseModelWorker { | ||||
/** | |||||
* 模块/页面保存:opts根据模型做些个性化处理,如果是模块,需要添加子页面 | |||||
* @param bean | |||||
* @param listFormChild | |||||
*/ | |||||
public void saveForm(ModelForm bean, List<ModelForm> listFormChild) { | public void saveForm(ModelForm bean, List<ModelForm> listFormChild) { | ||||
SwMap opts = bean.getOpts(); | SwMap opts = bean.getOpts(); | ||||
if (opts != null) { | if (opts != null) { | ||||
@@ -62,4 +67,12 @@ public class BaseModelWorker { | |||||
return page; | return page; | ||||
} | } | ||||
/** | |||||
* 根据模型生成页面 | |||||
* @param bean | |||||
*/ | |||||
public void buildSaveModel(ModelForm bean) { | |||||
} | |||||
} | } |
@@ -5,6 +5,7 @@ import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
import cc.smtweb.framework.core.util.CommUtil; | import cc.smtweb.framework.core.util.CommUtil; | ||||
import cc.smtweb.framework.core.util.JsonUtil; | |||||
import cc.smtweb.framework.core.util.StringUtil; | import cc.smtweb.framework.core.util.StringUtil; | ||||
import cc.smtweb.system.bpm.web.design.form.ModelForm; | import cc.smtweb.system.bpm.web.design.form.ModelForm; | ||||
import cc.smtweb.system.bpm.web.design.form.ModelFormCache; | import cc.smtweb.system.bpm.web.design.form.ModelFormCache; | ||||
@@ -27,8 +28,9 @@ public class LcSinlgeWorker extends BaseModelWorker { | |||||
SwMap cfgPage = new SwMap(); | SwMap cfgPage = new SwMap(); | ||||
cfg.put(ModelFormHelper.OPT_PAGE, cfgPage); | cfg.put(ModelFormHelper.OPT_PAGE, cfgPage); | ||||
String formName = ModelFormHelper.getPageName(bean) + StringUtil.upFirst(SwEnum.PageType.LIST.value); | 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; | ModelForm page; | ||||
if (bean.isNew()) {//新增 | if (bean.isNew()) {//新增 | ||||
page = createPage(bean, SwEnum.PageType.LIST.value); | page = createPage(bean, SwEnum.PageType.LIST.value); | ||||
@@ -41,4 +41,9 @@ public class ModelFactory { | |||||
BaseModelWorker worker = getWorker(bean); | BaseModelWorker worker = getWorker(bean); | ||||
worker.saveForm(bean, listFormChild); | worker.saveForm(bean, listFormChild); | ||||
} | } | ||||
public void buildSaveModel(ModelForm bean) { | |||||
BaseModelWorker worker = getWorker(bean); | |||||
worker.buildSaveModel(bean); | |||||
} | |||||
} | } |
@@ -165,6 +165,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler { | |||||
} | } | ||||
//暂时不考虑list保存的情况 | //暂时不考虑list保存的情况 | ||||
bean.getData().putAll(data); | bean.getData().putAll(data); | ||||
bean.setIsNew(false); | |||||
} | } | ||||
return bean; | return bean; | ||||
@@ -363,7 +363,7 @@ public class EntityDao<T> extends AbstractEntityDao<T> { | |||||
args.add(readValue(bean, f)); | args.add(readValue(bean, f)); | ||||
sTitle += "+" + modelTable.findFieldTitle(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) + " 不能重复!"); | throw new BizException(sTitle.substring(1) + " 不能重复!"); | ||||
} | } | ||||
} | } |
@@ -24,7 +24,6 @@ public class DefaultDelHandler<T extends DefaultEntity> extends AbstractDelHandl | |||||
protected void checkValid() { | protected void checkValid() { | ||||
EntityHelper.checkExists(tableName, id); | EntityHelper.checkExists(tableName, id); | ||||
// ModelTable table = ModelTableCache.getInstance().getByName(tableName); | // ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ||||
//todo 检查外键引用的使用情况 | |||||
} | } | ||||
@@ -62,6 +62,7 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan | |||||
@Override | @Override | ||||
protected void readFromPage() { | protected void readFromPage() { | ||||
bean.readFromMap(params); | bean.readFromMap(params); | ||||
bean.setIsNew(isNew); | |||||
} | } | ||||
@Override | @Override | ||||
@@ -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" | |||||
} | } |