@@ -52,6 +52,7 @@ public class ModelFactory { | |||||
worker.saveForm(bean, listFormChild); | worker.saveForm(bean, listFormChild); | ||||
} | } | ||||
//构建模板 | |||||
public void buildSaveModel(ModelForm bean) { | public void buildSaveModel(ModelForm bean) { | ||||
BaseModelWorker worker = getWorker(bean); | BaseModelWorker worker = getWorker(bean); | ||||
worker.buildSaveModel(bean); | worker.buildSaveModel(bean); | ||||
@@ -1,7 +1,9 @@ | |||||
package cc.smtweb.system.bpm.web.engine.dynPage; | 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.common.SwMap; | ||||
import cc.smtweb.framework.core.exception.BizException; | 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.mvc.service.AbstractHandler; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.system.bpm.web.design.form.ModelForm; | import cc.smtweb.system.bpm.web.design.form.ModelForm; | ||||
@@ -41,6 +43,26 @@ public abstract class AbstractDynPageHandler extends AbstractHandler { | |||||
return datasets.findByName(name); | 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() { | protected PageDataset findMasterDataset() { | ||||
return datasets.findMasterDataset(); | return datasets.findMasterDataset(); | ||||
@@ -37,6 +37,27 @@ public class DynPageProvider extends AbstractCompProvider { | |||||
}); | }); | ||||
} | } | ||||
public <T extends DefaultEntity> T loadBean(PageDataset pageDataSet, SwMap filter) { | |||||
return doGetData("b_" + pageDataSet.id, () -> { | |||||
ModelTable masterTable = ModelTableCache.getInstance().get(pageDataSet.masterTable); | |||||
EntityDao<T> 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 extends DefaultEntity> T loadBean(String tableName, long id) { | public <T extends DefaultEntity> T loadBean(String tableName, long id) { | ||||
return doGetData(tableName + "." + id, () -> { | return doGetData(tableName + "." + id, () -> { | ||||
EntityDao<T> bdao = (EntityDao<T>) DbEngine.getInstance().findDao(tableName); | EntityDao<T> bdao = (EntityDao<T>) DbEngine.getInstance().findDao(tableName); | ||||
@@ -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.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.system.bpm.web.engine.flow.FlowInstance; | 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.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 | * 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; | protected FlowInstance flowInstance; | ||||
@Override | @Override | ||||
@@ -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.FlowHelper; | ||||
import cc.smtweb.system.bpm.web.engine.flow.FlowInstance; | 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.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 | * Created by Akmm at 2022-08-26 17:15 | ||||
* 流程加载 | * 流程加载 | ||||
*/ | */ | ||||
public class FlowSingleLoadHandler<T extends DefaultEntity> extends LCSingleLoadHandler<T> implements FlowListener { | |||||
public class FlowSingleLoadHandler<T extends DefaultEntity> extends ModelLoadHandler<T> implements FlowListener { | |||||
protected FlowInstance flowInstance; | protected FlowInstance flowInstance; | ||||
@Override | @Override | ||||
protected void afterAdd(SwMap ret, T bean) { | |||||
protected void afterAdd(SwMap ret) { | |||||
super.afterAdd(ret); | |||||
flowInstance = FlowInstance.createByBillType(us, this, form.getBillType()); | flowInstance = FlowInstance.createByBillType(us, this, form.getBillType()); | ||||
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | |||||
bean.setEntityId(flowInstance.getProcInst().getId()); | bean.setEntityId(flowInstance.getProcInst().getId()); | ||||
ret.put(cardDataset.name, DynRetBean.createBean(bean)); | |||||
ret.put(ModelHelper.DATASET_NAME_CARD, DynRetBean.createBean(bean)); | |||||
flowInstance.setPageRetExtra(ret); | flowInstance.setPageRetExtra(ret); | ||||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ||||
@@ -35,13 +34,13 @@ public class FlowSingleLoadHandler<T extends DefaultEntity> extends LCSingleLoad | |||||
} | } | ||||
@Override | @Override | ||||
public R load() { | |||||
SwMap ret = new SwMap(); | |||||
protected void load(SwMap ret, SwMap filter) { | |||||
//过滤条件 | //过滤条件 | ||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
long taskId = params.readLong("taskId"); | long taskId = params.readLong("taskId"); | ||||
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | |||||
PageDataset cardDataset = findCardDataset(ModelHelper.DATASET_NAME_CARD); | |||||
T bean = provider.loadBean(cardDataset, id); | T bean = provider.loadBean(cardDataset, id); | ||||
ret.put(cardDataset.name, DynRetBean.createBean(bean)); | ret.put(cardDataset.name, DynRetBean.createBean(bean)); | ||||
@@ -51,8 +50,6 @@ public class FlowSingleLoadHandler<T extends DefaultEntity> extends LCSingleLoad | |||||
flowInstance.setPageRetExtra(ret); | flowInstance.setPageRetExtra(ret); | ||||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ||||
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.create(flowInstance.loadComment(), 0))); | ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.create(flowInstance.loadComment(), 0))); | ||||
afterLoad(ret, bean); | |||||
return R.success(ret); | |||||
} | } | ||||
@Override | @Override | ||||
@@ -5,23 +5,22 @@ import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||||
import cc.smtweb.framework.core.exception.BizException; | import cc.smtweb.framework.core.exception.BizException; | ||||
import cc.smtweb.framework.core.mvc.service.SwListData; | import cc.smtweb.framework.core.mvc.service.SwListData; | ||||
import cc.smtweb.framework.core.util.DateUtil; | 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.dynPage.DynRetBean; | ||||
import cc.smtweb.system.bpm.web.engine.flow.FlowHelper; | 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.FlowInstance; | ||||
import cc.smtweb.system.bpm.web.engine.flow.FlowListener; | 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 | * Created by Akmm at 2022-08-26 16:47 | ||||
* 带流程的简单卡片之保存 | * 带流程的简单卡片之保存 | ||||
*/ | */ | ||||
public class FlowSingleSaveHandler<T extends DefaultEntity> extends LCSingleSaveHandler<T> implements FlowListener { | |||||
public class FlowSingleSaveHandler<T extends DefaultEntity> extends ModelSaveHandler<T> implements FlowListener { | |||||
protected FlowInstance flowInstance; | protected FlowInstance flowInstance; | ||||
@Override | @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 id = params.readLong("id"); | ||||
long taskId = params.readLong("taskId"); | long taskId = params.readLong("taskId"); | ||||
@@ -43,18 +42,17 @@ public class FlowSingleSaveHandler<T extends DefaultEntity> extends LCSingleSave | |||||
flowInstance.getProcInst().setUrl(getBillUrl()); | flowInstance.getProcInst().setUrl(getBillUrl()); | ||||
} | } | ||||
flowInstance.getProcInst().setBillInfo(getBillInfo()); | flowInstance.getProcInst().setBillInfo(getBillInfo()); | ||||
return bean; | |||||
} | } | ||||
@Override | @Override | ||||
protected void saveBean(T bean) { | |||||
super.saveBean(bean); | |||||
protected void doSave() { | |||||
super.doSave(); | |||||
flowInstance.save(); | flowInstance.save(); | ||||
} | } | ||||
@Override | @Override | ||||
protected void afterSave(SwMap ret, T bean) { | |||||
super.afterSave(ret, bean); | |||||
protected void afterSave(SwMap ret) { | |||||
super.afterSave(ret); | |||||
flowInstance.setPageRetExtra(ret); | flowInstance.setPageRetExtra(ret); | ||||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ||||
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.EMPTY)); | ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.EMPTY)); | ||||
@@ -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.AbstractHandler; | ||||
import cc.smtweb.framework.core.mvc.service.IWorker; | import cc.smtweb.framework.core.mvc.service.IWorker; | ||||
import cc.smtweb.framework.core.session.UserSession; | 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; | import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; | ||||
/** | /** | ||||
@@ -27,17 +27,17 @@ public class FlowSingleService extends LCSingleService { | |||||
} | } | ||||
@Override | @Override | ||||
protected LCSingleSaveHandler getSaveHandler() { | |||||
protected ModelSaveHandler getSaveHandler() { | |||||
return new FlowSingleSaveHandler(); | return new FlowSingleSaveHandler(); | ||||
} | } | ||||
@Override | @Override | ||||
protected LCSingleLoadHandler getLoadHandler() { | |||||
protected ModelLoadHandler getLoadHandler() { | |||||
return new FlowSingleLoadHandler(); | return new FlowSingleLoadHandler(); | ||||
} | } | ||||
@Override | @Override | ||||
protected LCSingleDelHandler getDelHandler() { | |||||
protected ModelDelHandler getDelHandler() { | |||||
return new FlowDelHandler(); | return new FlowDelHandler(); | ||||
} | } | ||||
@@ -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.FlowHelper; | ||||
import cc.smtweb.system.bpm.web.engine.flow.FlowInstance; | 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.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 | * Created by Akmm at 2022-09-01 15:03 | ||||
@@ -33,7 +33,7 @@ public class FlowTransHandler<T extends DefaultEntity> extends AbstractDynPageHa | |||||
private SwMap buildRetData() { | private SwMap buildRetData() { | ||||
SwMap ret = new SwMap(); | 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); | flowInstance.setPageRetExtra(ret); | ||||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ||||
@@ -52,7 +52,7 @@ public class FlowTransHandler<T extends DefaultEntity> extends AbstractDynPageHa | |||||
} | } | ||||
protected void loadBean() { | protected void loadBean() { | ||||
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | |||||
PageDataset cardDataset = findCardDataset(ModelHelper.DATASET_NAME_CARD); | |||||
bean = provider.loadBean(cardDataset, billId); | bean = provider.loadBean(cardDataset, billId); | ||||
} | } | ||||
@@ -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.AbstractCache; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | 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 | * 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} | * 删除指定数据集,入参{pageId, dataset, id} | ||||
* | * | ||||
@@ -27,7 +28,7 @@ public class LCSingleDelHandler extends AbstractDynPageHandler { | |||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
if (id == 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); | if (id == 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); | ||||
//数据集 | //数据集 | ||||
PageDataset pageDataSet = LCSingleHelper.findCardDataset(datasets); | |||||
PageDataset pageDataSet = findCardDataset(cardDsName); | |||||
checkBean(pageDataSet, id); | checkBean(pageDataSet, id); | ||||
@@ -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; | |||||
} | |||||
} |
@@ -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.R; | ||||
import cc.smtweb.framework.core.common.SwConsts; | 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 | * Created by Akmm at 2022-08-16 15:43 | ||||
*/ | */ | ||||
public class LCSingleLoadHandler<T extends DefaultEntity> extends AbstractDynPageHandler { | |||||
public class ModelLoadHandler<T extends DefaultEntity> extends AbstractDynPageHandler { | |||||
protected T bean; | |||||
protected String cardDsName = ModelHelper.DATASET_NAME_CARD; | |||||
//新增卡片操作,初始化定义的数据集 | //新增卡片操作,初始化定义的数据集 | ||||
public R add() { | public R add() { | ||||
SwMap ret = new SwMap(); | SwMap ret = new SwMap(); | ||||
bean = addBean(ret, cardDsName); | |||||
afterAdd(ret); | |||||
return R.success(ret); | |||||
} | |||||
//创建一个bean,并加到返回对象中 | |||||
protected <E extends DefaultEntity> E addBean(SwMap ret, String dsName) { | |||||
//返回的数据,以dataset.name为key,查出的结果(bean或list)为value | //返回的数据,以dataset.name为key,查出的结果(bean或list)为value | ||||
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | |||||
PageDataset cardDataset = findCardDataset(dsName); | |||||
ModelTable table = cardDataset._getModelTable(); | ModelTable table = cardDataset._getModelTable(); | ||||
if (table == null) throw new SwException("卡片主表未找到!"); | if (table == null) throw new SwException("卡片主表未找到!"); | ||||
final EntityDao<T> dao = DbEngine.getInstance().findDao(table.getName()); | |||||
T bean = dao.createBean(us.getUserId()); | |||||
bean.setEntityId(DbEngine.getInstance().nextId()); | |||||
final EntityDao<E> 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 | //新增初始化 - bean | ||||
protected void afterAdd(SwMap ret, T bean) { | |||||
} | |||||
//加载之后 | |||||
protected void afterLoad(SwMap ret, T bean) { | |||||
protected void afterAdd(SwMap ret) { | |||||
} | } | ||||
public R load() { | public R load() { | ||||
SwMap ret = new SwMap(); | SwMap ret = new SwMap(); | ||||
//过滤条件 | //过滤条件 | ||||
SwMap filter = params.readMap("filter"); | 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 extends DefaultEntity> 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) { | protected DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) { | ||||
DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet); | DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet); | ||||
listHandler.init(params, us); | listHandler.init(params, us); | ||||
@@ -70,28 +83,34 @@ public class LCSingleLoadHandler<T extends DefaultEntity> extends AbstractDynPag | |||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
public R list() { | |||||
protected R list(String dsName) { | |||||
//过滤条件 | //过滤条件 | ||||
SwMap filter = params.readMap("filter"); | SwMap filter = params.readMap("filter"); | ||||
//对应的数据集定义 | //对应的数据集定义 | ||||
PageDataset pageDataSet = LCSingleHelper.findListDataset(datasets); | |||||
PageDataset pageDataSet = findListDataset(dsName); | |||||
DynRetBean bean = DynRetBean.createList(getListWorker(filter, pageDataSet).buildListData()); | DynRetBean bean = DynRetBean.createList(getListWorker(filter, pageDataSet).buildListData()); | ||||
return R.success(bean); | 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 | * @return | ||||
*/ | */ | ||||
public R getTotal() { | public R getTotal() { | ||||
//数据集 | |||||
PageDataset pageDataSet = LCSingleHelper.findListDataset(datasets); | |||||
//过滤条件 | |||||
SwMap filter = params.readMap("filter"); | |||||
return getListWorker(filter, pageDataSet).getTotal(); | |||||
return getTotal(ModelHelper.DATASET_NAME_LIST); | |||||
} | } | ||||
} | } |
@@ -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.AbstractCache; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
@@ -27,64 +27,67 @@ import java.util.Map; | |||||
/** | /** | ||||
* Created by Akmm at 2022/4/21 17:53 | * Created by Akmm at 2022/4/21 17:53 | ||||
* 保存操作 | |||||
* 模型保存操作 | |||||
* 入参:{pageId, data:} | * 入参:{pageId, data:} | ||||
*/ | */ | ||||
public class LCSingleSaveHandler<T extends DefaultEntity> extends AbstractDynPageHandler { | |||||
private Map<String, List<T>> mapTreeBean = new HashMap<>(); | |||||
public class ModelSaveHandler<T extends DefaultEntity> extends AbstractDynPageHandler { | |||||
private Map<String, List<? extends DefaultEntity>> mapTreeBean = new HashMap<>(); | |||||
protected T bean; | |||||
protected String cardDsName = ModelHelper.DATASET_NAME_CARD; | |||||
/** | /** | ||||
* 保存指定数据集操作,入参:{pageId,dataset:"", data:{form:{},list: {total:0,rows:[]}}, filter:{}} | * 保存指定数据集操作,入参:{pageId,dataset:"", data:{form:{},list: {total:0,rows:[]}}, filter:{}} | ||||
*/ | */ | ||||
public R save() { | public R save() { | ||||
//数据集 | |||||
String dbName = params.readString("dataset"); | |||||
SwMap filter = params.readMap("filter"); | SwMap filter = params.readMap("filter"); | ||||
//待保存数据 | //待保存数据 | ||||
SwMap data = params.readMap("data"); | 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() { | DbEngine.getInstance().doTrans(new IDbWorker() { | ||||
@Override | @Override | ||||
public void work() { | public void work() { | ||||
saveBean(bean); | |||||
doSave(); | |||||
} | } | ||||
@Override | @Override | ||||
public void doAfterDbCommit() { | public void doAfterDbCommit() { | ||||
afterCommit(bean); | |||||
doAfterCommit(); | |||||
} | } | ||||
@Override | @Override | ||||
public void doAfterDbRollback() { | public void doAfterDbRollback() { | ||||
afterRollback(bean); | |||||
doAfterRollback(); | |||||
} | } | ||||
}); | }); | ||||
bean.removeStatus(); | 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); | return R.success(ret); | ||||
} | } | ||||
protected void afterSave(SwMap ret, T bean) { | |||||
protected void afterSave(SwMap ret) { | |||||
} | } | ||||
/** | /** | ||||
* 从页面获取待保存的bean | * 从页面获取待保存的bean | ||||
* | * | ||||
* @param pageDataSet | * @param pageDataSet | ||||
* @param data | |||||
* @param pageData | |||||
* @return | * @return | ||||
*/ | */ | ||||
protected T readBeanFromPage(PageDataset pageDataSet, SwMap pageData) { | |||||
protected void readFromPage(SwMap pageData, SwMap filter) { | |||||
//读取待保存的bean | |||||
bean = readBeanFromPage(cardDsName, pageData, filter); | |||||
} | |||||
//给子类使用的工具方法:从页面读取一个bean | |||||
protected <E extends DefaultEntity> E readBeanFromPage(String dsName, SwMap pageData, SwMap filter) { | |||||
//对应的数据集定义 | |||||
PageDataset pageDataSet = findCardDataset(dsName); | |||||
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | ||||
if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name); | if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name); | ||||
@@ -94,24 +97,26 @@ public class LCSingleSaveHandler<T extends DefaultEntity> extends AbstractDynPag | |||||
if (data == null) throw new BizException("没有找到待保存的表数据:" + pageDataSet.name); | if (data == null) throw new BizException("没有找到待保存的表数据:" + pageDataSet.name); | ||||
boolean isNew = data.readBool(DefaultEntity.statusKey); | boolean isNew = data.readBool(DefaultEntity.statusKey); | ||||
EntityDao<T> dao = DbEngine.getInstance().findDao(table.getName()); | |||||
T bean; | |||||
EntityDao<E> dao = DbEngine.getInstance().findDao(table.getName()); | |||||
E vo; | |||||
if (isNew) { | if (isNew) { | ||||
bean = dao.createBean(); | |||||
vo = dao.createBean(); | |||||
//暂时不考虑list保存的情况 | //暂时不考虑list保存的情况 | ||||
bean.getData().putAll(data); | |||||
vo.getData().putAll(data); | |||||
} else { | } else { | ||||
long id = data.readLong(table.getIdField()); | 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); | throw new BizException("没有找到待保存的记录:" + table.getName() + "." + id); | ||||
} | } | ||||
//暂时不考虑list保存的情况 | //暂时不考虑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<T extends DefaultEntity> extends AbstractDynPag | |||||
* | * | ||||
* @param bean | * @param bean | ||||
*/ | */ | ||||
protected void checkBean(T bean) { | |||||
ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); | |||||
protected void checkValid() { | |||||
checkValid(bean); | |||||
} | |||||
//给子类使用的工具方法:校验bean | |||||
protected <E extends DefaultEntity> void checkValid(E vo) { | |||||
ModelTable table = ModelTableCache.getInstance().getByName(vo.getTableName()); | |||||
for (ModelField field : table.getFields()) { | for (ModelField field : table.getFields()) { | ||||
String value = bean.getStr(field.getName()); | |||||
String value = vo.getStr(field.getName()); | |||||
//非空校验 | //非空校验 | ||||
if (field.isNotNull() && StringUtils.isEmpty(value)) { | if (field.isNotNull() && StringUtils.isEmpty(value)) { | ||||
throw new BizException("字段不允许为空:" + field.getTitle()); | throw new BizException("字段不允许为空:" + field.getTitle()); | ||||
@@ -137,60 +147,77 @@ public class LCSingleSaveHandler<T extends DefaultEntity> extends AbstractDynPag | |||||
} | } | ||||
} | } | ||||
//唯一键校验 | //唯一键校验 | ||||
EntityDao<T> dao = DbEngine.getInstance().findDao(bean.getTableName()); | |||||
EntityDao<E> dao = DbEngine.getInstance().findDao(vo.getTableName()); | |||||
for (ModelIndex mi : table.getIndexes()) { | for (ModelIndex mi : table.getIndexes()) { | ||||
if (mi.isUnique()) { | 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<T> dao = DbEngine.getInstance().findDao(tableName); | |||||
if (bean.isNew()) { | |||||
dao.insertEntity(bean); | |||||
protected void doSave() { | |||||
saveBean(bean); | |||||
} | |||||
//给子类使用的工具方法:保存bean | |||||
protected <E extends DefaultEntity> void saveBean(E entity) { | |||||
final String tableName = entity.getTableName(); | |||||
EntityDao<E> dao = DbEngine.getInstance().findDao(tableName); | |||||
if (entity.isNew()) { | |||||
dao.insertEntity(entity); | |||||
} else { | } else { | ||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ||||
ModelField field = table.findFieldByType(SwEnum.FieldType.UPDATE_USER.value); | 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) { | if (table.getType() == SwEnum.TableType.TYPE_TREE.value) { | ||||
List<T> listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean); | |||||
List<E> listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(entity); | |||||
mapTreeBean.put(tableName, listTreeBean); | mapTreeBean.put(tableName, listTreeBean); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
protected void afterCommit(T bean) { | |||||
final String tableName = bean.getTableName(); | |||||
//保存后 | |||||
protected void doAfterCommit() { | |||||
commitBean(bean); | |||||
} | |||||
//给子类使用的工具方法:提交后事件 | |||||
protected <E extends DefaultEntity> void commitBean(E entity) { | |||||
final String tableName = entity.getTableName(); | |||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ||||
if (table.isNeedCache()) { | if (table.isNeedCache()) { | ||||
AbstractCache<DefaultEntity> cache = CacheManager.getIntance().getCache(tableName); | AbstractCache<DefaultEntity> cache = CacheManager.getIntance().getCache(tableName); | ||||
List<T> listTreeBean = mapTreeBean.get(tableName); | |||||
List<E> listTreeBean = (List<E>)mapTreeBean.get(tableName); | |||||
//树型表,父亲改变了,要多处理下缓存;还有个东东:级次码 | //树型表,父亲改变了,要多处理下缓存;还有个东东:级次码 | ||||
if (listTreeBean != null && !listTreeBean.isEmpty()) { | if (listTreeBean != null && !listTreeBean.isEmpty()) { | ||||
for (DefaultEntity b : listTreeBean) { | for (DefaultEntity b : listTreeBean) { | ||||
cache.put(b); | cache.put(b); | ||||
} | } | ||||
} else { | } else { | ||||
cache.put(bean); | |||||
cache.put(entity); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
protected void afterRollback(T bean) { | |||||
//事务回滚 | |||||
protected void doAfterRollback() { | |||||
rollBean(bean); | |||||
} | |||||
//给子类使用的工具方法:回滚指定的bean | |||||
protected <E extends DefaultEntity> void rollBean(E bean) { | |||||
final String tableName = bean.getTableName(); | final String tableName = bean.getTableName(); | ||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ModelTable table = ModelTableCache.getInstance().getByName(tableName); | ||||
if (table.isNeedCache()) { | if (table.isNeedCache()) { | ||||
AbstractCache<T> cache = CacheManager.getIntance().getCache(tableName); | |||||
AbstractCache<E> cache = CacheManager.getIntance().getCache(tableName); | |||||
cache.reset(bean); | 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()); | ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); | ||||
for (PageDatasetFilter f : pageDataSet.filters) { | for (PageDatasetFilter f : pageDataSet.filters) { | ||||
String v = bean.getStr(f.field); | String v = bean.getStr(f.field); |
@@ -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()); | |||||
} | |||||
} |
@@ -1,32 +1,24 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; | package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; | ||||
import cc.smtweb.framework.core.common.R; | 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.AbsDelHandler; | ||||
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler; | |||||
/** | /** | ||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/9/2 11:44 | * @Date : 2022/9/2 11:44 | ||||
*/ | */ | ||||
public class LCLC1DelHandler extends AbsDelHandler { | |||||
public class LCLC1DelHandler extends ModelDelHandler { | |||||
/** | /** | ||||
* 左列表删除 | * 左列表删除 | ||||
* | * | ||||
* @return | * @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 | * @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(); | |||||
} | } | ||||
} | } |
@@ -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.R; | ||||
import cc.smtweb.framework.core.common.SwMap; | 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.dynPage.DynRetBean; | ||||
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsLoadHandler; | 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 | * @Author:lip | ||||
* @Date : 2022/9/2 11:44 | * @Date : 2022/9/2 11:44 | ||||
*/ | */ | ||||
public class LCLC1LoadHandler extends AbsLoadHandler { | |||||
public class LCLC1LoadHandler extends ModelLoadHandler<DefaultEntity> { | |||||
/** | /** | ||||
* 左表新增 | * 左表新增 | ||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
public R lAdd() { | 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 | * @return | ||||
*/ | */ | ||||
public R rAdd() { | 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 | * @return | ||||
*/ | */ | ||||
public R lLoad() { | 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 | * @return | ||||
*/ | */ | ||||
public R rLoad() { | 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 | * @return | ||||
*/ | */ | ||||
public R lList() { | 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 | * @return | ||||
*/ | */ | ||||
public R rList() { | 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 | * @return | ||||
*/ | */ | ||||
public R getLTotal() { | public R getLTotal() { | ||||
return doTotal(LCLC1Define.dsLList); | |||||
return super.getTotal(LCLC1Define.dsLList); | |||||
} | } | ||||
/** | /** | ||||
@@ -86,6 +86,6 @@ public class LCLC1LoadHandler extends AbsLoadHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R getRTotal() { | public R getRTotal() { | ||||
return doTotal(LCLC1Define.dsRList); | |||||
return super.getTotal(LCLC1Define.dsRList); | |||||
} | } | ||||
} | } |
@@ -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.common.R; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | 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.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 | * @Author:lip | ||||
* @Date : 2022/9/2 11:44 | * @Date : 2022/9/2 11:44 | ||||
*/ | */ | ||||
public class LCLC1SaveHandler extends AbsSaveHandler { | |||||
public class LCLC1SaveHandler extends ModelSaveHandler<DefaultEntity> { | |||||
/** | /** | ||||
* 左表保存 | * 左表保存 | ||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
public R lSave() { | 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 | * @return | ||||
*/ | */ | ||||
public R rSave() { | public R rSave() { | ||||
DefaultEntity bean = doSave(LCLC1Define.dsRCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsRCard, bean.getData())); | |||||
cardDsName = LCLC1Define.dsRCard; | |||||
return super.save(); | |||||
} | } | ||||
} | } |
@@ -7,33 +7,30 @@ import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.mvc.service.AbstractHandler; | import cc.smtweb.framework.core.mvc.service.AbstractHandler; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; | 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 | * @Author:lip | ||||
* @Date : 2022/9/2 11:34 | * @Date : 2022/9/2 11:34 | ||||
*/ | */ | ||||
@SwService | @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 | @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) { | 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) { | 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) { | 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) { | 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()); | |||||
} | } | ||||
//列表数据 | //列表数据 | ||||
@@ -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.design.form.define.PageDataset; | ||||
import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; | 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.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 org.springframework.util.Assert; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
@@ -96,6 +96,6 @@ public class LCMsSaveHandler extends AbsSaveHandler<DefaultEntity> { | |||||
afterRollback(masterBean); | afterRollback(masterBean); | ||||
} | } | ||||
}); | }); | ||||
return R.success(LCSingleHelper.buildRetData(masterDataSet.name, masterBean.getData())); | |||||
return R.success(ModelHelper.buildRetData(masterDataSet.name, masterBean.getData())); | |||||
} | } | ||||
} | } |
@@ -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"; | |||||
} |
@@ -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(); | |||||
} | |||||
} |
@@ -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); | |||||
} | |||||
} |
@@ -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())); | |||||
} | |||||
} |
@@ -4,69 +4,17 @@ import cc.smtweb.framework.core.annotation.SwBody; | |||||
import cc.smtweb.framework.core.annotation.SwService; | import cc.smtweb.framework.core.annotation.SwService; | ||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwMap; | 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.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 | * @Author:lip | ||||
* @Date : 2022/8/27 13:54 | * @Date : 2022/8/27 13:54 | ||||
*/ | */ | ||||
@SwService | @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 { | |||||
} | } |
@@ -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; | |||||
} | |||||
} |
@@ -7,73 +7,13 @@ import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.mvc.service.AbstractHandler; | import cc.smtweb.framework.core.mvc.service.AbstractHandler; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; | 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 | * Created by Akmm at 2022-08-12 15:37 | ||||
* 单页面简单列表卡片服务类 | * 单页面简单列表卡片服务类 | ||||
*/ | */ | ||||
@SwService | @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 { | |||||
} | } |
@@ -1,16 +1,16 @@ | |||||
package cc.smtweb.system.bpm.web.sys.base.billType; | package cc.smtweb.system.bpm.web.sys.base.billType; | ||||
import cc.smtweb.framework.core.exception.BizException; | 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; | import org.apache.commons.lang3.StringUtils; | ||||
/** | /** | ||||
* Created by Akmm at 2022-08-25 19:11 | * Created by Akmm at 2022-08-25 19:11 | ||||
*/ | */ | ||||
public class BillTypeSaveHandler extends LCSingleSaveHandler<BillType> { | |||||
public class BillTypeSaveHandler extends ModelSaveHandler<BillType> { | |||||
@Override | @Override | ||||
protected void checkBean(BillType bean) { | |||||
super.checkBean(bean); | |||||
protected void checkValid() { | |||||
super.checkValid(); | |||||
if (StringUtils.isEmpty(bean.getCode())) { | if (StringUtils.isEmpty(bean.getCode())) { | ||||
throw new BizException("编码不能为空!"); | throw new BizException("编码不能为空!"); | ||||
} | } | ||||
@@ -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.annotation.SwService; | ||||
import cc.smtweb.framework.core.mvc.service.AbstractHandler; | import cc.smtweb.framework.core.mvc.service.AbstractHandler; | ||||
import cc.smtweb.framework.core.mvc.service.DefaultComboHandler; | 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; | import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; | ||||
/** | /** | ||||
@@ -19,7 +19,7 @@ public class BillTypeService extends LCSingleService { | |||||
} | } | ||||
@Override | @Override | ||||
protected LCSingleSaveHandler getSaveHandler() { | |||||
protected ModelSaveHandler<BillType> getSaveHandler() { | |||||
return new BillTypeSaveHandler(); | return new BillTypeSaveHandler(); | ||||
} | } | ||||
} | } |
@@ -6,7 +6,7 @@ package cc.smtweb.framework.core.common; | |||||
public interface SwConsts { | public interface SwConsts { | ||||
class SysParam { | class SysParam { | ||||
//开发调试模式 | //开发调试模式 | ||||
public static boolean SYS_DEBUG = false; | |||||
public static boolean SYS_DEBUG = true; | |||||
//系统启动完成 | //系统启动完成 | ||||
public static boolean SYS_STARTED = false; | public static boolean SYS_STARTED = false; | ||||
//运行的项目,多个用半角逗号分隔 | //运行的项目,多个用半角逗号分隔 | ||||