diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java index f137609..74897ef 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/model/ModelFactory.java @@ -52,6 +52,7 @@ public class ModelFactory { worker.saveForm(bean, listFormChild); } + //构建模板 public void buildSaveModel(ModelForm bean) { BaseModelWorker worker = getWorker(bean); worker.buildSaveModel(bean); diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java index 53a6f18..d54ce28 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java @@ -1,7 +1,9 @@ package cc.smtweb.system.bpm.web.engine.dynPage; +import cc.smtweb.framework.core.common.SwEnum; import cc.smtweb.framework.core.common.SwMap; 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.session.UserSession; import cc.smtweb.system.bpm.web.design.form.ModelForm; @@ -41,6 +43,26 @@ public abstract class AbstractDynPageHandler extends AbstractHandler { return datasets.findByName(name); } + //找可编辑卡片数据集 + protected PageDataset findCardDataset(String dsName) { + PageDataset cardDataset = datasets.findByName(dsName); + if (cardDataset == null) throw new SwException("没有找到卡片数据集(" + dsName + ")!"); + if (!SwEnum.DatasetType.FORM.value.equals(cardDataset.type)) {//单表 + throw new SwException("卡片数据集定义错误(" + dsName + ")!"); + } + return cardDataset; + } + + //找列表数据集 + protected PageDataset findListDataset(String dsName) { + PageDataset listDataset = datasets.findByName(dsName); + if (listDataset == null) throw new SwException("没有找到列表数据集(" + dsName + ")!"); + if (!SwEnum.DatasetType.LIST.value.equals(listDataset.type)) {//列表 + throw new SwException("列表数据集定义错误(" + dsName + ")!"); + } + return listDataset; + } + //获取第一个,主数据集 protected PageDataset findMasterDataset() { return datasets.findMasterDataset(); diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageProvider.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageProvider.java index 180b78b..e3641b5 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageProvider.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageProvider.java @@ -37,6 +37,27 @@ public class DynPageProvider extends AbstractCompProvider { }); } + public T loadBean(PageDataset pageDataSet, SwMap filter) { + return doGetData("b_" + pageDataSet.id, () -> { + ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable); + EntityDao dao = DbEngine.getInstance().findDao(masterTable.getName()); + T bean = dao.createBean(); + + SqlNamedPara sqlPara = DynPageHelper.buildSelectSql(pageDataSet, filter); + SwMap map = DbEngine.getInstance().queryEntityN(sqlPara.sql, sqlPara.mapParas, SwMap.class); + if (map == null) { + return bean; + //throw new BizException("没有找到指定数据(ds=" + pageDataSet.name + ")"); + } + + EntityHelper.loadBeanText(masterTable.getName(), map, sqlPara.mapFieldAlias); + DynPageHelper.setCalcFields(map, pageDataSet); + + bean.getData().putAll(map); + return bean; + }); + } + public T loadBean(String tableName, long id) { return doGetData(tableName + "." + id, () -> { EntityDao bdao = (EntityDao) DbEngine.getInstance().findDao(tableName); diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowDelHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowDelHandler.java index fb3282e..3e58c16 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowDelHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowDelHandler.java @@ -3,13 +3,13 @@ package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single; import cc.smtweb.framework.core.db.vo.ModelTable; import cc.smtweb.system.bpm.web.engine.flow.FlowInstance; import cc.smtweb.system.bpm.web.engine.flow.FlowListener; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleDelHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler; /** * Created by Akmm at 2022-09-01 15:03 * 流程删除 */ -public class FlowDelHandler extends LCSingleDelHandler implements FlowListener { +public class FlowDelHandler extends ModelDelHandler implements FlowListener { protected FlowInstance flowInstance; @Override diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java index e6d63d9..eb6c293 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java @@ -10,24 +10,23 @@ import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; import cc.smtweb.system.bpm.web.engine.flow.FlowHelper; import cc.smtweb.system.bpm.web.engine.flow.FlowInstance; import cc.smtweb.system.bpm.web.engine.flow.FlowListener; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleLoadHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelLoadHandler; /** * Created by Akmm at 2022-08-26 17:15 * 流程加载 */ -public class FlowSingleLoadHandler extends LCSingleLoadHandler implements FlowListener { +public class FlowSingleLoadHandler extends ModelLoadHandler implements FlowListener { protected FlowInstance flowInstance; @Override - protected void afterAdd(SwMap ret, T bean) { + protected void afterAdd(SwMap ret) { + super.afterAdd(ret); flowInstance = FlowInstance.createByBillType(us, this, form.getBillType()); - PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); bean.setEntityId(flowInstance.getProcInst().getId()); - - ret.put(cardDataset.name, DynRetBean.createBean(bean)); + ret.put(ModelHelper.DATASET_NAME_CARD, DynRetBean.createBean(bean)); flowInstance.setPageRetExtra(ret); ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); @@ -35,13 +34,13 @@ public class FlowSingleLoadHandler extends LCSingleLoad } @Override - public R load() { - SwMap ret = new SwMap(); + protected void load(SwMap ret, SwMap filter) { + //过滤条件 long id = params.readLong("id"); long taskId = params.readLong("taskId"); - PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); + PageDataset cardDataset = findCardDataset(ModelHelper.DATASET_NAME_CARD); T bean = provider.loadBean(cardDataset, id); ret.put(cardDataset.name, DynRetBean.createBean(bean)); @@ -51,8 +50,6 @@ public class FlowSingleLoadHandler extends LCSingleLoad flowInstance.setPageRetExtra(ret); ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.create(flowInstance.loadComment(), 0))); - afterLoad(ret, bean); - return R.success(ret); } @Override diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java index 82c05af..72ed92e 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java @@ -5,23 +5,22 @@ import cc.smtweb.framework.core.db.impl.DefaultEntity; import cc.smtweb.framework.core.exception.BizException; import cc.smtweb.framework.core.mvc.service.SwListData; import cc.smtweb.framework.core.util.DateUtil; -import cc.smtweb.system.bpm.web.design.form.define.PageDataset; import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; import cc.smtweb.system.bpm.web.engine.flow.FlowHelper; import cc.smtweb.system.bpm.web.engine.flow.FlowInstance; import cc.smtweb.system.bpm.web.engine.flow.FlowListener; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler; /** * Created by Akmm at 2022-08-26 16:47 * 带流程的简单卡片之保存 */ -public class FlowSingleSaveHandler extends LCSingleSaveHandler implements FlowListener { +public class FlowSingleSaveHandler extends ModelSaveHandler implements FlowListener { protected FlowInstance flowInstance; @Override - protected T readBeanFromPage(PageDataset pageDataSet, SwMap pageData) { - T bean = super.readBeanFromPage(pageDataSet, pageData); + protected void readFromPage(SwMap pageData, SwMap filter) { + super.readFromPage(pageData, filter); long id = params.readLong("id"); long taskId = params.readLong("taskId"); @@ -43,18 +42,17 @@ public class FlowSingleSaveHandler extends LCSingleSave flowInstance.getProcInst().setUrl(getBillUrl()); } flowInstance.getProcInst().setBillInfo(getBillInfo()); - return bean; } @Override - protected void saveBean(T bean) { - super.saveBean(bean); + protected void doSave() { + super.doSave(); flowInstance.save(); } @Override - protected void afterSave(SwMap ret, T bean) { - super.afterSave(ret, bean); + protected void afterSave(SwMap ret) { + super.afterSave(ret); flowInstance.setPageRetExtra(ret); ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.EMPTY)); diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java index 6b7845f..a017a49 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java @@ -7,9 +7,9 @@ import cc.smtweb.framework.core.common.SwMap; import cc.smtweb.framework.core.mvc.service.AbstractHandler; import cc.smtweb.framework.core.mvc.service.IWorker; import cc.smtweb.framework.core.session.UserSession; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleDelHandler; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleLoadHandler; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelLoadHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler; import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; /** @@ -27,17 +27,17 @@ public class FlowSingleService extends LCSingleService { } @Override - protected LCSingleSaveHandler getSaveHandler() { + protected ModelSaveHandler getSaveHandler() { return new FlowSingleSaveHandler(); } @Override - protected LCSingleLoadHandler getLoadHandler() { + protected ModelLoadHandler getLoadHandler() { return new FlowSingleLoadHandler(); } @Override - protected LCSingleDelHandler getDelHandler() { + protected ModelDelHandler getDelHandler() { return new FlowDelHandler(); } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowTransHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowTransHandler.java index 0616a41..9fa1019 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowTransHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowTransHandler.java @@ -11,7 +11,7 @@ import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; import cc.smtweb.system.bpm.web.engine.flow.FlowHelper; import cc.smtweb.system.bpm.web.engine.flow.FlowInstance; import cc.smtweb.system.bpm.web.engine.flow.FlowListener; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper; /** * Created by Akmm at 2022-09-01 15:03 @@ -33,7 +33,7 @@ public class FlowTransHandler extends AbstractDynPageHa private SwMap buildRetData() { SwMap ret = new SwMap(); - ret.put(LCSingleHelper.DATASET_NAME_CARD, DynRetBean.createBean(bean)); + ret.put(ModelHelper.DATASET_NAME_CARD, DynRetBean.createBean(bean)); flowInstance.setPageRetExtra(ret); ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); @@ -52,7 +52,7 @@ public class FlowTransHandler extends AbstractDynPageHa } protected void loadBean() { - PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); + PageDataset cardDataset = findCardDataset(ModelHelper.DATASET_NAME_CARD); bean = provider.loadBean(cardDataset, billId); } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleDelHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelDelHandler.java similarity index 91% rename from smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleDelHandler.java rename to smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelDelHandler.java index 4cd0444..57f38d3 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleDelHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelDelHandler.java @@ -1,4 +1,4 @@ -package cc.smtweb.system.bpm.web.engine.model.listcard.single; +package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler; import cc.smtweb.framework.core.cache.AbstractCache; import cc.smtweb.framework.core.cache.CacheManager; @@ -17,7 +17,8 @@ import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; * Created by Akmm at 2022/4/21 17:53 * 删除操作 */ -public class LCSingleDelHandler extends AbstractDynPageHandler { +public class ModelDelHandler extends AbstractDynPageHandler { + protected String cardDsName = ModelHelper.DATASET_NAME_CARD; /** * 删除指定数据集,入参{pageId, dataset, id} * @@ -27,7 +28,7 @@ public class LCSingleDelHandler extends AbstractDynPageHandler { long id = params.readLong("id"); if (id == 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); //数据集 - PageDataset pageDataSet = LCSingleHelper.findCardDataset(datasets); + PageDataset pageDataSet = findCardDataset(cardDsName); checkBean(pageDataSet, id); diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelHelper.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelHelper.java new file mode 100644 index 0000000..6f06771 --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelHelper.java @@ -0,0 +1,25 @@ +package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler; + +import cc.smtweb.framework.core.common.SwEnum; +import cc.smtweb.framework.core.common.SwMap; +import cc.smtweb.framework.core.exception.SwException; +import cc.smtweb.system.bpm.web.design.form.ModelForm; +import cc.smtweb.system.bpm.web.design.form.ModelFormHelper; +import cc.smtweb.system.bpm.web.design.form.define.PageDataset; +import cc.smtweb.system.bpm.web.design.form.define.PageDatasets; +import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; + +/** + * Created by Akmm at 2022-08-16 16:07 + * 常量定义 + */ +public interface ModelHelper { + String DATASET_NAME_LIST = "list"; + String DATASET_NAME_CARD = "card"; + + static SwMap buildRetData(String dsName, SwMap data) { + SwMap mapRet = new SwMap(); + mapRet.put(dsName, DynRetBean.createBean(data)); + return mapRet; + } +} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleLoadHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelLoadHandler.java similarity index 54% rename from smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleLoadHandler.java rename to smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelLoadHandler.java index b2aa1fa..e184105 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleLoadHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelLoadHandler.java @@ -1,4 +1,4 @@ -package cc.smtweb.system.bpm.web.engine.model.listcard.single; +package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler; import cc.smtweb.framework.core.common.R; import cc.smtweb.framework.core.common.SwConsts; @@ -16,49 +16,62 @@ import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; /** * Created by Akmm at 2022-08-16 15:43 */ -public class LCSingleLoadHandler extends AbstractDynPageHandler { +public class ModelLoadHandler extends AbstractDynPageHandler { + protected T bean; + protected String cardDsName = ModelHelper.DATASET_NAME_CARD; //新增卡片操作,初始化定义的数据集 public R add() { SwMap ret = new SwMap(); + bean = addBean(ret, cardDsName); + afterAdd(ret); + return R.success(ret); + } + + //创建一个bean,并加到返回对象中 + protected E addBean(SwMap ret, String dsName) { //返回的数据,以dataset.name为key,查出的结果(bean或list)为value - PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); + PageDataset cardDataset = findCardDataset(dsName); ModelTable table = cardDataset._getModelTable(); if (table == null) throw new SwException("卡片主表未找到!"); - final EntityDao dao = DbEngine.getInstance().findDao(table.getName()); - - T bean = dao.createBean(us.getUserId()); - bean.setEntityId(DbEngine.getInstance().nextId()); + final EntityDao dao = DbEngine.getInstance().findDao(table.getName()); - ret.put(cardDataset.name, DynRetBean.createBean(bean)); + E entity = dao.createBean(us.getUserId()); + entity.setEntityId(DbEngine.getInstance().nextId()); - afterAdd(ret, bean); - return R.success(ret); + ret.put(dsName, DynRetBean.createBean(entity)); + return entity; } //新增初始化 - bean - protected void afterAdd(SwMap ret, T bean) { - } - - //加载之后 - protected void afterLoad(SwMap ret, T bean) { + protected void afterAdd(SwMap ret) { } public R load() { SwMap ret = new SwMap(); //过滤条件 SwMap filter = params.readMap("filter"); - //对应的数据集定义 - PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); + load(ret, filter); + return R.success(ret); + } - T bean = provider.loadBean(cardDataset, filter.readLong(SwConsts.NAME_ID)); - ret.put(cardDataset.name, DynRetBean.createBean(bean)); + //从数据库加载bean,并设到返回值 + protected void load(SwMap ret, SwMap filter) { + PageDataset cardDataset = findCardDataset(cardDsName); + bean = provider.loadBean(cardDataset, filter.readLong(SwConsts.NAME_ID)); + ret.put(cardDsName, DynRetBean.createBean(bean)); + } - afterLoad(ret, bean); - return R.success(ret); + //给子类使用的工具方法:根据数据集配置,读取bean,并加到返回值 + protected E loadBean(SwMap ret, String dsName, SwMap filter) { + PageDataset cardDataset = findCardDataset(dsName); + E bean = provider.loadBean(cardDataset, filter); + ret.put(dsName, DynRetBean.createBean(bean)); + return bean; } + protected DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) { DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet); listHandler.init(params, us); @@ -70,28 +83,34 @@ public class LCSingleLoadHandler extends AbstractDynPag * * @return */ - public R list() { + protected R list(String dsName) { //过滤条件 SwMap filter = params.readMap("filter"); //对应的数据集定义 - PageDataset pageDataSet = LCSingleHelper.findListDataset(datasets); - + PageDataset pageDataSet = findListDataset(dsName); DynRetBean bean = DynRetBean.createList(getListWorker(filter, pageDataSet).buildListData()); - return R.success(bean); } + protected R getTotal(String dsName) { + //数据集 + PageDataset pageDataSet = findListDataset(dsName); + //过滤条件 + SwMap filter = params.readMap("filter"); + + return getListWorker(filter, pageDataSet).getTotal(); + } + + public R list() { + return list(ModelHelper.DATASET_NAME_LIST); + } + /** * 计算分页数据 * * @return */ public R getTotal() { - //数据集 - PageDataset pageDataSet = LCSingleHelper.findListDataset(datasets); - //过滤条件 - SwMap filter = params.readMap("filter"); - - return getListWorker(filter, pageDataSet).getTotal(); + return getTotal(ModelHelper.DATASET_NAME_LIST); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleSaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelSaveHandler.java similarity index 64% rename from smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleSaveHandler.java rename to smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelSaveHandler.java index 151b334..407e9f9 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleSaveHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelSaveHandler.java @@ -1,4 +1,4 @@ -package cc.smtweb.system.bpm.web.engine.model.listcard.single; +package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler; import cc.smtweb.framework.core.cache.AbstractCache; import cc.smtweb.framework.core.cache.CacheManager; @@ -27,64 +27,67 @@ import java.util.Map; /** * Created by Akmm at 2022/4/21 17:53 - * 保存操作 + * 模型保存操作 * 入参:{pageId, data:} */ -public class LCSingleSaveHandler extends AbstractDynPageHandler { - private Map> mapTreeBean = new HashMap<>(); +public class ModelSaveHandler extends AbstractDynPageHandler { + private Map> mapTreeBean = new HashMap<>(); + protected T bean; + protected String cardDsName = ModelHelper.DATASET_NAME_CARD; /** * 保存指定数据集操作,入参:{pageId,dataset:"", data:{form:{},list: {total:0,rows:[]}}, filter:{}} */ public R save() { - //数据集 - String dbName = params.readString("dataset"); SwMap filter = params.readMap("filter"); //待保存数据 SwMap data = params.readMap("data"); - if (data == null) throw new BizException("没有收到待保存的的数据:" + dbName + "!"); - //对应的数据集定义 - PageDataset pageDataSet = LCSingleHelper.findCardDataset(datasets); - //读取待保存的bean - T bean = readBeanFromPage(pageDataSet, data); - if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上 - setLinkValue(pageDataSet, bean, f -> filter.get(f.name)); - } - checkBean(bean); + if (data == null) throw new BizException("没有收到待保存的的数据!"); + readFromPage(data, filter); + checkValid(); DbEngine.getInstance().doTrans(new IDbWorker() { @Override public void work() { - saveBean(bean); + doSave(); } @Override public void doAfterDbCommit() { - afterCommit(bean); + doAfterCommit(); } @Override public void doAfterDbRollback() { - afterRollback(bean); + doAfterRollback(); } }); bean.removeStatus(); - SwMap ret = LCSingleHelper.buildRetData(pageDataSet.name, bean.getData()); - afterSave(ret, bean); + SwMap ret = ModelHelper.buildRetData(cardDsName, bean.getData()); + afterSave(ret); return R.success(ret); } - protected void afterSave(SwMap ret, T bean) { + protected void afterSave(SwMap ret) { } /** * 从页面获取待保存的bean * * @param pageDataSet - * @param data + * @param pageData * @return */ - protected T readBeanFromPage(PageDataset pageDataSet, SwMap pageData) { + protected void readFromPage(SwMap pageData, SwMap filter) { + //读取待保存的bean + bean = readBeanFromPage(cardDsName, pageData, filter); + } + + //给子类使用的工具方法:从页面读取一个bean + protected E readBeanFromPage(String dsName, SwMap pageData, SwMap filter) { + //对应的数据集定义 + PageDataset pageDataSet = findCardDataset(dsName); + ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name); @@ -94,24 +97,26 @@ public class LCSingleSaveHandler extends AbstractDynPag if (data == null) throw new BizException("没有找到待保存的表数据:" + pageDataSet.name); boolean isNew = data.readBool(DefaultEntity.statusKey); - EntityDao dao = DbEngine.getInstance().findDao(table.getName()); - T bean; + EntityDao dao = DbEngine.getInstance().findDao(table.getName()); + E vo; if (isNew) { - bean = dao.createBean(); + vo = dao.createBean(); //暂时不考虑list保存的情况 - bean.getData().putAll(data); + vo.getData().putAll(data); } else { long id = data.readLong(table.getIdField()); - bean = dao.queryEntity(id); - if (bean == null) { + vo = dao.queryEntity(id); + if (vo == null) { throw new BizException("没有找到待保存的记录:" + table.getName() + "." + id); } //暂时不考虑list保存的情况 - bean.getData().putAll(data); - bean.setIsNew(false); + vo.getData().putAll(data); + vo.setIsNew(false); } - - return bean; + if (filter != null && vo.isNew()) {//有过滤条件,将关联的值设上 + setLinkValue(pageDataSet, vo, f -> filter.get(f.name)); + } + return vo; } /** @@ -119,10 +124,15 @@ public class LCSingleSaveHandler extends AbstractDynPag * * @param bean */ - protected void checkBean(T bean) { - ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); + protected void checkValid() { + checkValid(bean); + } + + //给子类使用的工具方法:校验bean + protected void checkValid(E vo) { + ModelTable table = ModelTableCache.getInstance().getByName(vo.getTableName()); for (ModelField field : table.getFields()) { - String value = bean.getStr(field.getName()); + String value = vo.getStr(field.getName()); //非空校验 if (field.isNotNull() && StringUtils.isEmpty(value)) { throw new BizException("字段不允许为空:" + field.getTitle()); @@ -137,60 +147,77 @@ public class LCSingleSaveHandler extends AbstractDynPag } } //唯一键校验 - EntityDao dao = DbEngine.getInstance().findDao(bean.getTableName()); + EntityDao dao = DbEngine.getInstance().findDao(vo.getTableName()); for (ModelIndex mi : table.getIndexes()) { if (mi.isUnique()) { - dao.checkUnique(bean, mi.getFields().split(",")); + dao.checkUnique(vo, mi.getFields().split(",")); } } } - protected void saveBean(T bean) { - final String tableName = bean.getTableName(); - EntityDao dao = DbEngine.getInstance().findDao(tableName); - if (bean.isNew()) { - dao.insertEntity(bean); + protected void doSave() { + saveBean(bean); + } + + //给子类使用的工具方法:保存bean + protected void saveBean(E entity) { + final String tableName = entity.getTableName(); + EntityDao dao = DbEngine.getInstance().findDao(tableName); + if (entity.isNew()) { + dao.insertEntity(entity); } else { ModelTable table = ModelTableCache.getInstance().getByName(tableName); ModelField field = table.findFieldByType(SwEnum.FieldType.UPDATE_USER.value); - if (field != null) bean.put(field.getName(), us.getUserId()); + if (field != null) entity.put(field.getName(), us.getUserId()); - dao.updateEntity(bean); + dao.updateEntity(entity); if (table.getType() == SwEnum.TableType.TYPE_TREE.value) { - List listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean); + List listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(entity); mapTreeBean.put(tableName, listTreeBean); } } } - protected void afterCommit(T bean) { - final String tableName = bean.getTableName(); + //保存后 + protected void doAfterCommit() { + commitBean(bean); + } + + //给子类使用的工具方法:提交后事件 + protected void commitBean(E entity) { + final String tableName = entity.getTableName(); ModelTable table = ModelTableCache.getInstance().getByName(tableName); if (table.isNeedCache()) { AbstractCache cache = CacheManager.getIntance().getCache(tableName); - List listTreeBean = mapTreeBean.get(tableName); + List listTreeBean = (List)mapTreeBean.get(tableName); //树型表,父亲改变了,要多处理下缓存;还有个东东:级次码 if (listTreeBean != null && !listTreeBean.isEmpty()) { for (DefaultEntity b : listTreeBean) { cache.put(b); } } else { - cache.put(bean); + cache.put(entity); } } } - protected void afterRollback(T bean) { + //事务回滚 + protected void doAfterRollback() { + rollBean(bean); + } + + //给子类使用的工具方法:回滚指定的bean + protected void rollBean(E bean) { final String tableName = bean.getTableName(); ModelTable table = ModelTableCache.getInstance().getByName(tableName); if (table.isNeedCache()) { - AbstractCache cache = CacheManager.getIntance().getCache(tableName); + AbstractCache cache = CacheManager.getIntance().getCache(tableName); cache.reset(bean); } } //将关联的值设上 - protected void setLinkValue(PageDataset pageDataSet, T bean, IGetValue iGetValue) { + protected void setLinkValue(PageDataset pageDataSet, DefaultEntity bean, IGetValue iGetValue) { ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); for (PageDatasetFilter f : pageDataSet.filters) { String v = bean.getStr(f.field); diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelService.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelService.java new file mode 100644 index 0000000..5a64c73 --- /dev/null +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelService.java @@ -0,0 +1,77 @@ +package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler; + +import cc.smtweb.framework.core.annotation.SwBody; +import cc.smtweb.framework.core.common.R; +import cc.smtweb.framework.core.common.SwMap; +import cc.smtweb.framework.core.mvc.service.AbstractHandler; +import cc.smtweb.framework.core.session.UserSession; +import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; + +/** + * Created by Akmm at 2022-08-12 15:37 + * 单页面简单列表卡片服务类 + */ +public class ModelService extends DynPageService { + public final static String TYPE_MODEL_LIST = "modelList"; + public final static String TYPE_MODEL_ADD = "modelAdd"; + public final static String TYPE_MODEL_LOAD = "modelLoad"; + public final static String TYPE_MODEL_SAVE = "modelSave"; + public final static String TYPE_MODEL_DEL = "modelDel"; + + @Override + protected AbstractHandler createHandler(String type) { + switch (type) { + case TYPE_MODEL_LIST: + case TYPE_MODEL_LOAD: + case TYPE_MODEL_ADD: + return getLoadHandler(); + case TYPE_MODEL_SAVE: + return getSaveHandler(); + case TYPE_MODEL_DEL: + return getDelHandler(); + } + return super.createHandler(type); + } + + protected ModelSaveHandler getSaveHandler() { + return new ModelSaveHandler(); + } + + protected ModelLoadHandler getLoadHandler() { + return new ModelLoadHandler(); + } + + protected ModelDelHandler getDelHandler() { + return new ModelDelHandler(); + } + + //保存 + public R modelSave(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((ModelSaveHandler) handler).save()); + } + + //读取 + public R modelLoad(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((ModelLoadHandler) handler).load()); + } + + //读取 + public R modelAdd(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((ModelLoadHandler) handler).add()); + } + + //删除 + public R modelDel(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((ModelDelHandler) handler).del()); + } + + //列表数据 + public R modelList(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((ModelLoadHandler) handler).list()); + } + + //列表总记录数及合计栏 + public R modelListTotal(@SwBody SwMap params, UserSession us) { + return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((ModelLoadHandler) handler).getTotal()); + } +} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java index a25ad52..137f34e 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java @@ -1,32 +1,24 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; import cc.smtweb.framework.core.common.R; +import cc.smtweb.framework.core.db.impl.DefaultEntity; import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler; /** * @Author:lip * @Date : 2022/9/2 11:44 */ -public class LCLC1DelHandler extends AbsDelHandler { +public class LCLC1DelHandler extends ModelDelHandler { /** * 左列表删除 * * @return */ - public R lLDel() { - doDel(LCLC1Define.dsLList); - return R.success(); - } - - /** - * 左卡片删除 - * - * @return - */ - public R lCDel() { - doDel(LCLC1Define.dsLCard); - return R.success(); + public R lDel() { + cardDsName = LCLC1Define.dsLCard; + return super.del(); } /** @@ -34,18 +26,8 @@ public class LCLC1DelHandler extends AbsDelHandler { * * @return */ - public R rLDel() { - doDel(LCLC1Define.dsRList); - return R.success(); - } - - /** - * 右卡片删除 - * - * @return - */ - public R rCDel() { - doDel(LCLC1Define.dsRCard); - return R.success(); + public R rDel() { + cardDsName = LCLC1Define.dsRCard; + return super.del(); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java index 247d636..5a47186 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java @@ -2,23 +2,25 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; import cc.smtweb.framework.core.common.R; import cc.smtweb.framework.core.common.SwMap; +import cc.smtweb.framework.core.db.impl.DefaultEntity; import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsLoadHandler; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelLoadHandler; /** * @Author:lip * @Date : 2022/9/2 11:44 */ -public class LCLC1LoadHandler extends AbsLoadHandler { +public class LCLC1LoadHandler extends ModelLoadHandler { /** * 左表新增 * * @return */ public R lAdd() { - SwMap data = doAdd(LCLC1Define.dsLCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsLCard, data)); + cardDsName = LCLC1Define.dsLCard; + return super.add(); } /** @@ -27,8 +29,8 @@ public class LCLC1LoadHandler extends AbsLoadHandler { * @return */ public R rAdd() { - SwMap data = doAdd(LCLC1Define.dsRCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsRCard, data)); + cardDsName = LCLC1Define.dsRCard; + return super.add(); } /** @@ -37,8 +39,8 @@ public class LCLC1LoadHandler extends AbsLoadHandler { * @return */ public R lLoad() { - SwMap bean = doLoadCard(LCLC1Define.dsLCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsLCard, bean)); + cardDsName = LCLC1Define.dsLCard; + return super.load(); } /** @@ -47,8 +49,8 @@ public class LCLC1LoadHandler extends AbsLoadHandler { * @return */ public R rLoad() { - SwMap bean = doLoadCard(LCLC1Define.dsRCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsRCard, bean)); + cardDsName = LCLC1Define.dsRCard; + return super.load(); } /** @@ -57,8 +59,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler { * @return */ public R lList() { - DynRetBean list = doList(LCLC1Define.dsLList); - return R.success(list); + return super.list(LCLC1Define.dsLCard); } /** @@ -67,8 +68,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler { * @return */ public R rList() { - DynRetBean list = doList(LCLC1Define.dsRList); - return R.success(list); + return super.list(LCLC1Define.dsRCard); } /** @@ -77,7 +77,7 @@ public class LCLC1LoadHandler extends AbsLoadHandler { * @return */ public R getLTotal() { - return doTotal(LCLC1Define.dsLList); + return super.getTotal(LCLC1Define.dsLList); } /** @@ -86,6 +86,6 @@ public class LCLC1LoadHandler extends AbsLoadHandler { * @return */ public R getRTotal() { - return doTotal(LCLC1Define.dsRList); + return super.getTotal(LCLC1Define.dsRList); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java index 128900a..2e7f6cc 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java @@ -3,21 +3,22 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; import cc.smtweb.framework.core.common.R; import cc.smtweb.framework.core.db.impl.DefaultEntity; import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsSaveHandler; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler; /** * @Author:lip * @Date : 2022/9/2 11:44 */ -public class LCLC1SaveHandler extends AbsSaveHandler { +public class LCLC1SaveHandler extends ModelSaveHandler { /** * 左表保存 * * @return */ public R lSave() { - DefaultEntity bean = doSave(LCLC1Define.dsLCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsLCard, bean.getData())); + cardDsName = LCLC1Define.dsLCard; + return super.save(); } /** @@ -26,7 +27,7 @@ public class LCLC1SaveHandler extends AbsSaveHandler { * @return */ public R rSave() { - DefaultEntity bean = doSave(LCLC1Define.dsRCard); - return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsRCard, bean.getData())); + cardDsName = LCLC1Define.dsRCard; + return super.save(); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java index 1df7f21..4b4ed97 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java @@ -7,33 +7,30 @@ import cc.smtweb.framework.core.common.SwMap; import cc.smtweb.framework.core.mvc.service.AbstractHandler; import cc.smtweb.framework.core.session.UserSession; import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelLoadHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelService; /** * @Author:lip * @Date : 2022/9/2 11:34 */ @SwService -public class LCLC1Service extends DynPageService { - protected final static String TYPE_MODEL_LIST = "modelList"; - protected final static String TYPE_MODEL_ADD = "modelAdd"; - protected final static String TYPE_MODEL_LOAD = "modelLoad"; - protected final static String TYPE_MODEL_SAVE = "modelSave"; - protected final static String TYPE_MODEL_DEL = "modelDel"; - - // +public class LCLC1Service extends ModelService { @Override - protected AbstractHandler createHandler(String type) { - switch (type) { - case TYPE_MODEL_LIST: - case TYPE_MODEL_LOAD: - case TYPE_MODEL_ADD: - return new LCLC1LoadHandler(); - case TYPE_MODEL_SAVE: - return new LCLC1SaveHandler(); - case TYPE_MODEL_DEL: - return new LCLC1DelHandler(); - } - return super.createHandler(type); + protected ModelSaveHandler getSaveHandler() { + return new LCLC1SaveHandler(); + } + + @Override + protected ModelLoadHandler getLoadHandler() { + return new LCLC1LoadHandler(); + } + + @Override + protected ModelDelHandler getDelHandler() { + return new LCLC1DelHandler(); } //保存 @@ -53,12 +50,12 @@ public class LCLC1Service extends DynPageService { //删除 public R modelLLDel(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).lLDel()); + return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).lDel()); } //删除 public R modelLCDel(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).lCDel()); + return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).lDel()); } //列表数据 @@ -89,12 +86,12 @@ public class LCLC1Service extends DynPageService { //删除 public R modelRLDel(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).rLDel()); + return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).rDel()); } //删除 public R modelRCDel(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).rCDel()); + return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).rDel()); } //列表数据 diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java index 4754bc9..25f6096 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java @@ -12,7 +12,7 @@ import cc.smtweb.framework.core.exception.BizException; import cc.smtweb.system.bpm.web.design.form.define.PageDataset; import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsSaveHandler; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper; import org.springframework.util.Assert; import java.util.ArrayList; @@ -96,6 +96,6 @@ public class LCMsSaveHandler extends AbsSaveHandler { afterRollback(masterBean); } }); - return R.success(LCSingleHelper.buildRetData(masterDataSet.name, masterBean.getData())); + return R.success(ModelHelper.buildRetData(masterDataSet.name, masterBean.getData())); } } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDefine.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDefine.java deleted file mode 100644 index 82581c9..0000000 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDefine.java +++ /dev/null @@ -1,12 +0,0 @@ -package cc.smtweb.system.bpm.web.engine.model.listcard.normal; - -/** - * @Author:lip - * @Date : 2022/9/2 15:23 - */ -public class LCNormalDefine { - //列表里数据集 - public static final String dsList = "list"; - //卡片数据集 - public static final String dsCard = "card"; -} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDelHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDelHandler.java deleted file mode 100644 index b780aba..0000000 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalDelHandler.java +++ /dev/null @@ -1,30 +0,0 @@ -package cc.smtweb.system.bpm.web.engine.model.listcard.normal; - -import cc.smtweb.framework.core.common.R; -import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler; - -/** - * Created by Akmm at 2022/4/21 17:53 - * 删除操作 - */ -public class LCNormalDelHandler extends AbsDelHandler { - /** - * 通过列表删除 - * - * @return - */ - public R listDel() { - doDel(LCNormalDefine.dsList); - return R.success(); - } - - /** - * 通过卡片删除 - * - * @return - */ - public R cardDel() { - doDel(LCNormalDefine.dsCard); - return R.success(); - } -} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalLoadHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalLoadHandler.java deleted file mode 100644 index 5e76454..0000000 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalLoadHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -package cc.smtweb.system.bpm.web.engine.model.listcard.normal; - -import cc.smtweb.framework.core.common.R; -import cc.smtweb.framework.core.common.SwMap; -import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; -import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; -import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsLoadHandler; - -/** - * @Author:lip - * @Date : 2022/8/29 14:37 - */ -public class LCNormalLoadHandler extends AbsLoadHandler { - - //新增卡片操作,初始化定义的数据集 - public R add() { - SwMap data = doAdd(LCNormalDefine.dsCard); - return R.success(ModelUtils.buildRetData(LCNormalDefine.dsCard, data)); - } - - public R load() { - SwMap data = doLoadCard(LCNormalDefine.dsCard); - return R.success(ModelUtils.buildRetData(LCNormalDefine.dsCard, data)); - } - - /** - * 列表数据 - * - * @return - */ - public R list() { - DynRetBean dynRetBean = doList(LCNormalDefine.dsList); - return R.success(dynRetBean); - } - - /** - * 计算分页数据 - * - * @return - */ - public R getTotal() { - return doTotal(LCNormalDefine.dsList); - } -} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalSaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalSaveHandler.java deleted file mode 100644 index 3b48992..0000000 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalSaveHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -package cc.smtweb.system.bpm.web.engine.model.listcard.normal; - -import cc.smtweb.framework.core.common.R; -import cc.smtweb.framework.core.db.impl.DefaultEntity; -import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; -import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsSaveHandler; - -/** - * @Author:lip - * @Date : 2022/9/2 14:56 - */ -public class LCNormalSaveHandler extends AbsSaveHandler { - /** - * @return - */ - public R save() { - DefaultEntity bean = doSave(LCNormalDefine.dsCard); - return R.success(ModelUtils.buildRetData(LCNormalDefine.dsCard, bean.getData())); - } - -} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalService.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalService.java index 1513364..2fc43f4 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalService.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalService.java @@ -4,69 +4,17 @@ 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.framework.core.mvc.service.AbstractHandler; import cc.smtweb.framework.core.session.UserSession; -import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelLoadHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelService; +import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; /** * @Author:lip * @Date : 2022/8/27 13:54 */ @SwService -public class LCNormalService extends DynPageService { - protected final static String TYPE_MODEL_LIST = "modelList"; - protected final static String TYPE_MODEL_ADD = "modelAdd"; - protected final static String TYPE_MODEL_LOAD = "modelLoad"; - protected final static String TYPE_MODEL_SAVE = "modelSave"; - protected final static String TYPE_MODEL_DEL = "modelDel"; - - @Override - protected AbstractHandler createHandler(String type) { - switch (type) { - case TYPE_MODEL_LIST: - case TYPE_MODEL_LOAD: - case TYPE_MODEL_ADD: - return new LCNormalLoadHandler(); - case TYPE_MODEL_SAVE: - return new LCNormalSaveHandler(); - case TYPE_MODEL_DEL: - return new LCNormalDelHandler(); - } - return super.createHandler(type); - } - - //保存 - public R modelSave(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCNormalSaveHandler) handler).save()); - } - - //列表删除 - public R modelLDel(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCNormalDelHandler) handler).listDel()); - } - - //卡片删除 - public R modelCDel(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCNormalDelHandler) handler).cardDel()); - } - - //读取 - public R modelLoad(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCNormalLoadHandler) handler).load()); - } - - //读取 - public R modelAdd(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCNormalLoadHandler) handler).add()); - } - - //列表数据 - public R modelList(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCNormalLoadHandler) handler).list()); - } - - //列表总记录数及合计栏 - public R modelListTotal(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCNormalLoadHandler) handler).getTotal()); - } +public class LCNormalService extends ModelService { } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleHelper.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleHelper.java deleted file mode 100644 index 0bbfe95..0000000 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleHelper.java +++ /dev/null @@ -1,43 +0,0 @@ -package cc.smtweb.system.bpm.web.engine.model.listcard.single; - -import cc.smtweb.framework.core.common.SwEnum; -import cc.smtweb.framework.core.common.SwMap; -import cc.smtweb.framework.core.exception.SwException; -import cc.smtweb.system.bpm.web.design.form.define.PageDataset; -import cc.smtweb.system.bpm.web.design.form.define.PageDatasets; -import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; - -/** - * Created by Akmm at 2022-08-16 16:07 - * 常量定义 - */ -public interface LCSingleHelper { - String DATASET_NAME_LIST = "list"; - String DATASET_NAME_CARD = "card"; - - //卡片数据集 - static PageDataset findCardDataset(PageDatasets datasets) { - PageDataset cardDataset = datasets.findByName(DATASET_NAME_CARD); - if (cardDataset == null) throw new SwException("没有找到卡片数据集!"); - if (!SwEnum.DatasetType.FORM.value.equals(cardDataset.type)) {//单表 - throw new SwException("卡片数据集定义错误!"); - } - return cardDataset; - } - - //列表数据集 - static PageDataset findListDataset(PageDatasets datasets) { - PageDataset cardDataset = datasets.findByName(DATASET_NAME_LIST); - if (cardDataset == null) throw new SwException("没有找到列表数据集!"); - if (!SwEnum.DatasetType.LIST.value.equals(cardDataset.type)) {//列表 - throw new SwException("列表数据集定义错误!"); - } - return cardDataset; - } - - static SwMap buildRetData(String dsName, SwMap data) { - SwMap mapRet = new SwMap(); - mapRet.put(dsName, DynRetBean.createBean(data)); - return mapRet; - } -} diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleService.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleService.java index 603c298..7a74d84 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleService.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleService.java @@ -7,73 +7,13 @@ import cc.smtweb.framework.core.common.SwMap; import cc.smtweb.framework.core.mvc.service.AbstractHandler; import cc.smtweb.framework.core.session.UserSession; import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelService; /** * Created by Akmm at 2022-08-12 15:37 * 单页面简单列表卡片服务类 */ @SwService -public class LCSingleService extends DynPageService { - public final static String TYPE_MODEL_LIST = "modelList"; - public final static String TYPE_MODEL_ADD = "modelAdd"; - public final static String TYPE_MODEL_LOAD = "modelLoad"; - public final static String TYPE_MODEL_SAVE = "modelSave"; - public final static String TYPE_MODEL_DEL = "modelDel"; - - @Override - protected AbstractHandler createHandler(String type) { - switch (type) { - case TYPE_MODEL_LIST: - case TYPE_MODEL_LOAD: - case TYPE_MODEL_ADD: - return getLoadHandler(); - case TYPE_MODEL_SAVE: - return getSaveHandler(); - case TYPE_MODEL_DEL: - return getDelHandler(); - } - return super.createHandler(type); - } - - protected LCSingleSaveHandler getSaveHandler() { - return new LCSingleSaveHandler(); - } - - protected LCSingleLoadHandler getLoadHandler() { - return new LCSingleLoadHandler(); - } - - protected LCSingleDelHandler getDelHandler() { - return new LCSingleDelHandler(); - } - - //保存 - public R modelSave(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCSingleSaveHandler) handler).save()); - } - - //读取 - public R modelLoad(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCSingleLoadHandler) handler).load()); - } - - //读取 - public R modelAdd(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCSingleLoadHandler) handler).add()); - } - - //删除 - public R modelDel(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCSingleDelHandler) handler).del()); - } - - //列表数据 - public R modelList(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCSingleLoadHandler) handler).list()); - } - - //列表总记录数及合计栏 - public R modelListTotal(@SwBody SwMap params, UserSession us) { - return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCSingleLoadHandler) handler).getTotal()); - } +public class LCSingleService extends ModelService { } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeSaveHandler.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeSaveHandler.java index 1aa545a..ec7d13e 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeSaveHandler.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeSaveHandler.java @@ -1,16 +1,16 @@ package cc.smtweb.system.bpm.web.sys.base.billType; import cc.smtweb.framework.core.exception.BizException; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler; import org.apache.commons.lang3.StringUtils; /** * Created by Akmm at 2022-08-25 19:11 */ -public class BillTypeSaveHandler extends LCSingleSaveHandler { +public class BillTypeSaveHandler extends ModelSaveHandler { @Override - protected void checkBean(BillType bean) { - super.checkBean(bean); + protected void checkValid() { + super.checkValid(); if (StringUtils.isEmpty(bean.getCode())) { throw new BizException("编码不能为空!"); } diff --git a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeService.java b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeService.java index d74b3d7..c278ecc 100644 --- a/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeService.java +++ b/smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeService.java @@ -3,7 +3,7 @@ package cc.smtweb.system.bpm.web.sys.base.billType; import cc.smtweb.framework.core.annotation.SwService; import cc.smtweb.framework.core.mvc.service.AbstractHandler; import cc.smtweb.framework.core.mvc.service.DefaultComboHandler; -import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; +import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler; import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; /** @@ -19,7 +19,7 @@ public class BillTypeService extends LCSingleService { } @Override - protected LCSingleSaveHandler getSaveHandler() { + protected ModelSaveHandler getSaveHandler() { return new BillTypeSaveHandler(); } } diff --git a/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java b/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java index 891fe09..a4149f5 100644 --- a/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java +++ b/smtweb-framework/core/src/main/java/cc/smtweb/framework/core/common/SwConsts.java @@ -6,7 +6,7 @@ package cc.smtweb.framework.core.common; public interface SwConsts { class SysParam { //开发调试模式 - public static boolean SYS_DEBUG = false; + public static boolean SYS_DEBUG = true; //系统启动完成 public static boolean SYS_STARTED = false; //运行的项目,多个用半角逗号分隔