@@ -436,6 +436,7 @@ public class ModelFormHelper { | |||||
PageDatasets datasets = form.getDatasets(); | PageDatasets datasets = form.getDatasets(); | ||||
SwMap tmplModel = JsonUtil.parse(form.getTmpl(), SwMap.class); | SwMap tmplModel = JsonUtil.parse(form.getTmpl(), SwMap.class); | ||||
tmplModel.put("title", form.getTitle()); | tmplModel.put("title", form.getTitle()); | ||||
tmplModel.put("name", form.getName()); | |||||
tmplModel.put("datasets", JsonUtil.bean2MapList(form.getDatasets().list)); | tmplModel.put("datasets", JsonUtil.bean2MapList(form.getDatasets().list)); | ||||
SwMap layout = tmplModel.readMap("layout"); | SwMap layout = tmplModel.readMap("layout"); | ||||
//用到的自定义控件 | //用到的自定义控件 | ||||
@@ -57,6 +57,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> { | |||||
ModelFormCache.getInstance().put(bean); | ModelFormCache.getInstance().put(bean); | ||||
if (listFormChild != null) { | if (listFormChild != null) { | ||||
for (ModelForm page : listFormChild) { | for (ModelForm page : listFormChild) { | ||||
page.removeStatus(); | |||||
ModelFormCache.getInstance().put(page); | ModelFormCache.getInstance().put(page); | ||||
} | } | ||||
} | } | ||||
@@ -0,0 +1,25 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
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; | |||||
import org.springframework.util.Assert; | |||||
/** | |||||
* @Author:lip | |||||
* @Date : 2022/9/2 15:22 | |||||
*/ | |||||
public class ModelUtils { | |||||
public static SwMap buildRetData(String dsName, SwMap data) { | |||||
SwMap mapRet = new SwMap(); | |||||
mapRet.put(dsName, DynRetBean.createBean(data)); | |||||
return mapRet; | |||||
} | |||||
public static PageDataset findPageDatasetByName(PageDatasets dataSets, String dsName) { | |||||
PageDataset pageDataset = dataSets.findByName(dsName); | |||||
Assert.notNull(pageDataset, "未获取到数据集:" + dsName); | |||||
return pageDataset; | |||||
} | |||||
} |
@@ -0,0 +1,84 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler; | |||||
import cc.smtweb.framework.core.cache.AbstractCache; | |||||
import cc.smtweb.framework.core.cache.CacheManager; | |||||
import cc.smtweb.framework.core.db.DbEngine; | |||||
import cc.smtweb.framework.core.db.EntityDao; | |||||
import cc.smtweb.framework.core.db.EntityHelper; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||||
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; | |||||
import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; | |||||
/** | |||||
* @Author:lip | |||||
* @Date : 2022/9/2 15:03 | |||||
*/ | |||||
public abstract class AbsDelHandler extends AbstractDynPageHandler { | |||||
/** | |||||
* 删除指定数据集,入参{pageId, dataset, id} | |||||
* | |||||
* @return | |||||
*/ | |||||
protected void doDel(String dsName) { | |||||
long id = params.readLong("id"); | |||||
if (id <= 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); | |||||
//数据集 | |||||
PageDataset pageDataset = ModelUtils.findPageDatasetByName(this.datasets,dsName); | |||||
// | |||||
checkBean(pageDataset, id); | |||||
// | |||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | |||||
@Override | |||||
public void work() { | |||||
ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable); | |||||
if (table == null) throw new BizException("没有找到指定的的表定义:" + pageDataset.name + "!"); | |||||
EntityDao dao = DbEngine.getInstance().findDao(table.getName()); | |||||
dao.deleteEntity(id); | |||||
localDel(id, table); | |||||
} | |||||
@Override | |||||
public void doAfterDbCommit() { | |||||
ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable); | |||||
if (table.isNeedCache()) { | |||||
AbstractCache cache = CacheManager.getIntance().getCache(table.getName()); | |||||
cache.remove(id); | |||||
} | |||||
afterCommit(id, table); | |||||
} | |||||
@Override | |||||
public void doAfterDbRollback() { | |||||
afterRollback(id); | |||||
} | |||||
}); | |||||
} | |||||
//回调:::删除之后 | |||||
protected void localDel(long id, ModelTable table) { | |||||
} | |||||
//回调:::提交成功后 | |||||
protected void afterCommit(long id, ModelTable table) { | |||||
} | |||||
//回调:::提交失败,事务回滚后 | |||||
protected void afterRollback(long id) { | |||||
} | |||||
/** | |||||
* 删除校验 | |||||
* | |||||
* @param pageDataSet | |||||
* @param id | |||||
*/ | |||||
protected void checkBean(PageDataset pageDataSet, long id) { | |||||
//校验外键引用关系 | |||||
EntityHelper.checkExists(pageDataSet.masterTable, id); | |||||
} | |||||
} |
@@ -0,0 +1,84 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler; | |||||
import cc.smtweb.framework.core.common.R; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageHelper; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; | |||||
import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; | |||||
import org.springframework.util.Assert; | |||||
/** | |||||
* @Author:lip | |||||
* @Date : 2022/9/2 15:03 | |||||
*/ | |||||
public abstract class AbsLoadHandler extends AbstractDynPageHandler { | |||||
/** | |||||
* 新增初始化 | |||||
* @param dsName | |||||
* @return | |||||
*/ | |||||
protected SwMap doAdd(String dsName) { | |||||
PageDataset addDataSet = this.datasets.findByName(dsName); | |||||
Assert.notNull(addDataSet, "未获取到数据集:" + dsName); | |||||
SwMap data; | |||||
//懒加载,给个空对象 | |||||
if (addDataSet.lazy) { | |||||
data = new SwMap(); | |||||
} else { | |||||
data = DynPageHelper.createBean(addDataSet); | |||||
} | |||||
return data; | |||||
} | |||||
/** | |||||
* 加载卡片数据 | |||||
* @param dsName | |||||
* @return | |||||
*/ | |||||
protected SwMap doLoadCard(String dsName){ | |||||
//过滤条件 | |||||
SwMap filter = params.readMap("filter"); | |||||
//对应的数据集定义 | |||||
PageDataset loadDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName); | |||||
return provider.loadData(filter, loadDataSet); | |||||
} | |||||
/** | |||||
* 列表数据 | |||||
* @return | |||||
*/ | |||||
protected DynRetBean doList(String dsName) { | |||||
//过滤条件 | |||||
SwMap filter = params.readMap("filter"); | |||||
//对应的数据集定义 | |||||
PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName); | |||||
return DynRetBean.createList(getListWorker(filter, listDataSet).buildListData()); | |||||
} | |||||
/** | |||||
* 计算分页数据 | |||||
* | |||||
* @return | |||||
*/ | |||||
protected R doTotal(String dsName) { | |||||
//过滤条件 | |||||
SwMap filter = params.readMap("filter"); | |||||
//对应的数据集定义 | |||||
PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName); | |||||
return getListWorker(filter, listDataSet).getTotal(); | |||||
} | |||||
protected DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) { | |||||
DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet); | |||||
listHandler.init(params, us); | |||||
return listHandler; | |||||
} | |||||
} |
@@ -0,0 +1,205 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler; | |||||
import cc.smtweb.framework.core.cache.AbstractCache; | |||||
import cc.smtweb.framework.core.cache.CacheManager; | |||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.DbEngine; | |||||
import cc.smtweb.framework.core.db.EntityDao; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||||
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | |||||
import cc.smtweb.framework.core.db.vo.ModelField; | |||||
import cc.smtweb.framework.core.db.vo.ModelIndex; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.mvc.service.TreeHelper; | |||||
import cc.smtweb.framework.core.util.StringUtil; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDatasetFilter; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; | |||||
import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | |||||
* @Author:lip | |||||
* @Date : 2022/9/2 15:02 | |||||
*/ | |||||
public abstract class AbsSaveHandler <T extends DefaultEntity> extends AbstractDynPageHandler { | |||||
private Map<String, List<T>> mapTreeBean = new HashMap<>(); | |||||
protected void setNewId(T bean) { | |||||
bean.setEntityId(DbEngine.getInstance().nextId()); | |||||
} | |||||
protected T doSave(String dsName) { | |||||
//数据集 | |||||
SwMap filter = params.readMap("filter"); | |||||
//待保存数据 | |||||
SwMap data = params.readMap("data"); | |||||
if (data == null) throw new BizException("没有收到待保存的的数据:" + dsName + "!"); | |||||
//对应的数据集定义 | |||||
PageDataset pageDataSet = ModelUtils.findPageDatasetByName(this.datasets,dsName); | |||||
//读取待保存的bean | |||||
T bean = readBeanFromPage(pageDataSet, data.readMap(dsName).readMap("form")); | |||||
if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上 | |||||
setLinkValue(pageDataSet, bean, f -> filter.get(f.name)); | |||||
} | |||||
checkBean(bean); | |||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | |||||
@Override | |||||
public void work() { | |||||
saveBean(bean); | |||||
} | |||||
@Override | |||||
public void doAfterDbCommit() { | |||||
afterCommit(bean); | |||||
} | |||||
@Override | |||||
public void doAfterDbRollback() { | |||||
afterRollback(bean); | |||||
} | |||||
}); | |||||
return bean; | |||||
} | |||||
/** | |||||
* 从页面获取待保存的bean | |||||
* | |||||
* @param pageDataSet | |||||
* @param data | |||||
* @return | |||||
*/ | |||||
protected T readBeanFromPage(PageDataset pageDataSet, SwMap data) { | |||||
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | |||||
if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name); | |||||
long id = data.readLong(table.getIdField()); | |||||
EntityDao<T> dao = DbEngine.getInstance().findDao(table.getName()); | |||||
T bean; | |||||
if (id <= 0L) { | |||||
bean = dao.createBean(); | |||||
bean.setIsNew(true); | |||||
//暂时不考虑list保存的情况 | |||||
bean.getData().putAll(data); | |||||
bean.setEntityId(DbEngine.getInstance().nextId()); | |||||
} else { | |||||
bean = dao.queryEntity(id); | |||||
if (bean == null) { | |||||
throw new BizException("没有找到待保存的记录:" + table.getName() + "." + id); | |||||
} | |||||
//暂时不考虑list保存的情况 | |||||
bean.getData().putAll(data); | |||||
bean.setIsNew(false); | |||||
} | |||||
return bean; | |||||
} | |||||
/** | |||||
* 保存校验 | |||||
* | |||||
* @param bean | |||||
*/ | |||||
protected void checkBean(T bean) { | |||||
ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); | |||||
for (ModelField field : table.getFields()) { | |||||
String value = bean.getStr(field.getName()); | |||||
//非空校验 | |||||
if (field.isNotNull() && StringUtils.isEmpty(value)) { | |||||
throw new BizException("字段不允许为空:" + field.getTitle()); | |||||
} | |||||
//长度校验 | |||||
if (StringUtils.isNotEmpty(value)) { | |||||
int len = SwEnum.DataType.instance.getByValue(field.getDataType()).dataLength; | |||||
if (len > 0 && StringUtil.getStrLenB(value) > len) { | |||||
throw new BizException("字段值超长:" + field.getTitle()); | |||||
} | |||||
} | |||||
} | |||||
//唯一键校验 | |||||
EntityDao<T> dao = DbEngine.getInstance().findDao(bean.getTableName()); | |||||
for (ModelIndex mi : table.getIndexes()) { | |||||
if (mi.isUnique()) { | |||||
dao.checkUnique(bean, 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); | |||||
} 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()); | |||||
dao.updateEntity(bean); | |||||
if (table.getType() == SwEnum.TableType.TYPE_TREE.value) { | |||||
List<T> listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean); | |||||
mapTreeBean.put(tableName, listTreeBean); | |||||
} | |||||
} | |||||
} | |||||
protected void afterCommit(T bean) { | |||||
final String tableName = bean.getTableName(); | |||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | |||||
if (table.isNeedCache()) { | |||||
AbstractCache<DefaultEntity> cache = CacheManager.getIntance().getCache(tableName); | |||||
List<T> listTreeBean = mapTreeBean.get(tableName); | |||||
//树型表,父亲改变了,要多处理下缓存;还有个东东:级次码 | |||||
if (listTreeBean != null && !listTreeBean.isEmpty()) { | |||||
for (DefaultEntity b : listTreeBean) { | |||||
cache.put(b); | |||||
} | |||||
} else { | |||||
cache.put(bean); | |||||
} | |||||
} | |||||
} | |||||
protected void afterRollback(T bean) { | |||||
final String tableName = bean.getTableName(); | |||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | |||||
if (table.isNeedCache()) { | |||||
AbstractCache<T> cache = CacheManager.getIntance().getCache(tableName); | |||||
cache.reset(bean); | |||||
} | |||||
} | |||||
//将关联的值设上 | |||||
protected void setLinkValue(PageDataset pageDataSet, T bean, IGetValue iGetValue) { | |||||
ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); | |||||
for (PageDatasetFilter f : pageDataSet.filters) { | |||||
String v = bean.getStr(f.field); | |||||
//有值,就不管 | |||||
if (v != null && !v.equals(table.findField(f.field).getDefaultValue())) continue; | |||||
if (SwEnum.FilterType.CONST.value.equals(f.type)) {//常量 | |||||
bean.put(f.field, f.value); | |||||
} else if (SwEnum.FilterType.PARAM.value.equals(f.type)) {//参数 | |||||
bean.put(f.field, f.value); | |||||
} else if (SwEnum.FilterType.LINK.value.equals(f.type)) {//参数 | |||||
Object value = iGetValue.getValue(f); | |||||
if (value != null) { | |||||
bean.put(f.field, value); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
public interface IGetValue { | |||||
Object getValue(PageDatasetFilter f); | |||||
} | |||||
} |
@@ -0,0 +1,12 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; | |||||
/** | |||||
* @Author:lip | |||||
* @Date : 2022/9/2 12:00 | |||||
*/ | |||||
public class LCLC1Define { | |||||
public static final String dsLList = "lList"; | |||||
public static final String dsLCard = "lCard"; | |||||
public static final String dsRList = "rList"; | |||||
public static final String dsRCard = "rCard"; | |||||
} |
@@ -1,30 +1,20 @@ | |||||
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.cache.AbstractCache; | |||||
import cc.smtweb.framework.core.cache.CacheManager; | |||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.db.DbEngine; | |||||
import cc.smtweb.framework.core.db.EntityDao; | |||||
import cc.smtweb.framework.core.db.EntityHelper; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||||
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; | |||||
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler; | |||||
/** | /** | ||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/9/2 11:44 | * @Date : 2022/9/2 11:44 | ||||
*/ | */ | ||||
public class LCLC1DelHandler extends AbstractDynPageHandler { | |||||
public class LCLC1DelHandler extends AbsDelHandler { | |||||
/** | /** | ||||
* 左列表删除 | * 左列表删除 | ||||
* @return | * @return | ||||
*/ | */ | ||||
public R lLDel(){ | public R lLDel(){ | ||||
del(LCLC1Handler.dsLList); | |||||
doDel(LCLC1Define.dsLList); | |||||
return R.success(); | return R.success(); | ||||
} | } | ||||
@@ -33,7 +23,7 @@ public class LCLC1DelHandler extends AbstractDynPageHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R lCDel(){ | public R lCDel(){ | ||||
del(LCLC1Handler.dsLCard); | |||||
doDel(LCLC1Define.dsLCard); | |||||
return R.success(); | return R.success(); | ||||
} | } | ||||
@@ -42,7 +32,7 @@ public class LCLC1DelHandler extends AbstractDynPageHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rLDel(){ | public R rLDel(){ | ||||
del(LCLC1Handler.dsRList); | |||||
doDel(LCLC1Define.dsRList); | |||||
return R.success(); | return R.success(); | ||||
} | } | ||||
@@ -51,56 +41,7 @@ public class LCLC1DelHandler extends AbstractDynPageHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rCDel(){ | public R rCDel(){ | ||||
del(LCLC1Handler.dsRCard); | |||||
doDel(LCLC1Define.dsRCard); | |||||
return R.success(); | return R.success(); | ||||
} | } | ||||
private void del(String dsName) { | |||||
long id = params.readLong("id"); | |||||
if (id == 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); | |||||
//数据集 | |||||
PageDataset pageDataset = this.datasets.findByName(dsName); | |||||
checkBean(pageDataset, id); | |||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | |||||
@Override | |||||
public void work() { | |||||
ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable); | |||||
if (table == null) throw new BizException("没有找到指定的的表定义:" + pageDataset.name + "!"); | |||||
EntityDao dao = DbEngine.getInstance().findDao(table.getName()); | |||||
dao.deleteEntity(id); | |||||
localDel(id, table); | |||||
} | |||||
@Override | |||||
public void doAfterDbCommit() { | |||||
ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable); | |||||
if (table.isNeedCache()) { | |||||
AbstractCache cache = CacheManager.getIntance().getCache(table.getName()); | |||||
cache.remove(id); | |||||
} | |||||
localDelSuccess(id, table); | |||||
} | |||||
}); | |||||
} | |||||
protected void localDel(long id, ModelTable table) { | |||||
} | |||||
protected void localDelSuccess(long id, ModelTable table) { | |||||
} | |||||
/** | |||||
* 删除校验 | |||||
* | |||||
* @param pageDataSet | |||||
* @param id | |||||
*/ | |||||
protected void checkBean(PageDataset pageDataSet, long id) { | |||||
//校验外键引用关系 | |||||
EntityHelper.checkExists(pageDataSet.masterTable, id); | |||||
} | |||||
} | } |
@@ -1,12 +0,0 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1; | |||||
/** | |||||
* @Author:lip | |||||
* @Date : 2022/9/2 12:00 | |||||
*/ | |||||
public class LCLC1Handler { | |||||
public static String dsLList = "lList"; | |||||
public static String dsLCard = "lCard"; | |||||
public static String dsRList = "rList"; | |||||
public static String dsRCard = "rCard"; | |||||
} |
@@ -2,26 +2,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.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageHelper; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler; | |||||
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.single.LCSingleHelper; | import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; | ||||
import org.springframework.util.Assert; | |||||
/** | /** | ||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/9/2 11:44 | * @Date : 2022/9/2 11:44 | ||||
*/ | */ | ||||
public class LCLC1LoadHandler extends AbstractDynPageHandler { | |||||
public class LCLC1LoadHandler extends AbsLoadHandler { | |||||
/** | /** | ||||
* 左表新增 | * 左表新增 | ||||
* @return | * @return | ||||
*/ | */ | ||||
public R lAdd() { | public R lAdd() { | ||||
SwMap data = add(LCLC1Handler.dsLCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsLCard, data)); | |||||
SwMap data = doAdd(LCLC1Define.dsLCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsLCard, data)); | |||||
} | } | ||||
/** | /** | ||||
@@ -29,21 +25,8 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rAdd() { | public R rAdd() { | ||||
SwMap data = add(LCLC1Handler.dsRCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsRCard, data)); | |||||
} | |||||
private SwMap add(String dsName) { | |||||
PageDataset addDataSet = this.datasets.findByName(dsName); | |||||
Assert.notNull(addDataSet, "未获取到数据集:" + dsName); | |||||
SwMap data; | |||||
//懒加载,给个空对象 | |||||
if (addDataSet.lazy) { | |||||
data = new SwMap(); | |||||
} else { | |||||
data = DynPageHelper.createBean(addDataSet); | |||||
} | |||||
return data; | |||||
SwMap data = doAdd(LCLC1Define.dsRCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsRCard, data)); | |||||
} | } | ||||
/** | /** | ||||
@@ -51,8 +34,8 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R lLoad() { | public R lLoad() { | ||||
SwMap bean = load(LCLC1Handler.dsLCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsLCard, bean)); | |||||
SwMap bean = doLoadCard(LCLC1Define.dsLCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsLCard, bean)); | |||||
} | } | ||||
/** | /** | ||||
@@ -60,25 +43,8 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rLoad() { | public R rLoad() { | ||||
SwMap bean = load(LCLC1Handler.dsRCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsRCard, bean)); | |||||
} | |||||
private SwMap load(String dsName) { | |||||
//过滤条件 | |||||
SwMap filter = params.readMap("filter"); | |||||
//对应的数据集定义 | |||||
PageDataset loadDataSet = this.datasets.findByName(dsName); | |||||
Assert.notNull(loadDataSet, "未获取到数据集:" + dsName); | |||||
return provider.loadData(filter, loadDataSet); | |||||
} | |||||
private DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) { | |||||
DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet); | |||||
listHandler.init(params, us); | |||||
return listHandler; | |||||
SwMap bean = doLoadCard(LCLC1Define.dsRCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsRCard, bean)); | |||||
} | } | ||||
/** | /** | ||||
@@ -86,7 +52,7 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R lList(){ | public R lList(){ | ||||
DynRetBean list = list(LCLC1Handler.dsLList); | |||||
DynRetBean list = doList(LCLC1Define.dsLList); | |||||
return R.success(list); | return R.success(list); | ||||
} | } | ||||
@@ -95,27 +61,16 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rList(){ | public R rList(){ | ||||
DynRetBean list = list(LCLC1Handler.dsRList); | |||||
DynRetBean list = doList(LCLC1Define.dsRList); | |||||
return R.success(list); | return R.success(list); | ||||
} | } | ||||
private DynRetBean list(String dsName) { | |||||
//过滤条件 | |||||
SwMap filter = params.readMap("filter"); | |||||
//对应的数据集定义 | |||||
PageDataset listDataSet = this.datasets.findByName(dsName); | |||||
Assert.notNull(listDataSet, "未获取到数据集:" + dsName); | |||||
return DynRetBean.createList(getListWorker(filter, listDataSet).buildListData()); | |||||
} | |||||
/** | /** | ||||
* 左列表分页数据 | * 左列表分页数据 | ||||
* @return | * @return | ||||
*/ | */ | ||||
public R getLTotal(){ | public R getLTotal(){ | ||||
return getTotal(LCLC1Handler.dsLList); | |||||
return doTotal(LCLC1Define.dsLList); | |||||
} | } | ||||
/** | /** | ||||
@@ -123,17 +78,6 @@ public class LCLC1LoadHandler extends AbstractDynPageHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R getRTotal(){ | public R getRTotal(){ | ||||
return getTotal(LCLC1Handler.dsRList); | |||||
} | |||||
private R getTotal(String dsName) { | |||||
//过滤条件 | |||||
SwMap filter = params.readMap("filter"); | |||||
//对应的数据集定义 | |||||
PageDataset listDataSet = this.datasets.findByName(dsName); | |||||
Assert.notNull(listDataSet, "未获取到数据集:" + dsName); | |||||
return getListWorker(filter, listDataSet).getTotal(); | |||||
return doTotal(LCLC1Define.dsRList); | |||||
} | } | ||||
} | } |
@@ -1,51 +1,22 @@ | |||||
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.cache.AbstractCache; | |||||
import cc.smtweb.framework.core.cache.CacheManager; | |||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwEnum; | |||||
import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.DbEngine; | |||||
import cc.smtweb.framework.core.db.EntityDao; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | |||||
import cc.smtweb.framework.core.db.vo.ModelField; | |||||
import cc.smtweb.framework.core.db.vo.ModelIndex; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||||
import cc.smtweb.framework.core.exception.BizException; | |||||
import cc.smtweb.framework.core.mvc.service.TreeHelper; | |||||
import cc.smtweb.framework.core.util.StringUtil; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDatasetFilter; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; | |||||
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.single.LCSingleHelper; | ||||
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | /** | ||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/9/2 11:44 | * @Date : 2022/9/2 11:44 | ||||
*/ | */ | ||||
public class LCLC1SaveHandler<T extends DefaultEntity> extends AbstractDynPageHandler { | |||||
private Map<String, List<T>> mapTreeBean = new HashMap<>(); | |||||
protected void setNewId(T bean) { | |||||
bean.setEntityId(DbEngine.getInstance().nextId()); | |||||
} | |||||
public class LCLC1SaveHandler extends AbsSaveHandler { | |||||
/** | /** | ||||
* 左表保存 | * 左表保存 | ||||
* @return | * @return | ||||
*/ | */ | ||||
public R lSave() { | public R lSave() { | ||||
T bean = save(LCLC1Handler.dsLCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsLCard, bean.getData())); | |||||
DefaultEntity bean = doSave(LCLC1Define.dsLCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsLCard, bean.getData())); | |||||
} | } | ||||
/** | /** | ||||
@@ -53,174 +24,7 @@ public class LCLC1SaveHandler<T extends DefaultEntity> extends AbstractDynPageHa | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R rSave() { | public R rSave() { | ||||
T bean = save(LCLC1Handler.dsRCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Handler.dsRCard, bean.getData())); | |||||
} | |||||
private T save(String dsName) { | |||||
//数据集 | |||||
SwMap filter = params.readMap("filter"); | |||||
//待保存数据 | |||||
SwMap data = params.readMap("data"); | |||||
if (data == null) throw new BizException("没有收到待保存的的数据:" + dsName + "!"); | |||||
//对应的数据集定义 | |||||
PageDataset pageDataSet = this.datasets.findByName(dsName); | |||||
//读取待保存的bean | |||||
T bean = readBeanFromPage(pageDataSet, data.readMap(dsName).readMap("form")); | |||||
if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上 | |||||
setLinkValue(pageDataSet, bean, f -> filter.get(f.name)); | |||||
} | |||||
checkBean(bean); | |||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | |||||
@Override | |||||
public void work() { | |||||
saveBean(bean); | |||||
} | |||||
@Override | |||||
public void doAfterDbCommit() { | |||||
afterCommit(bean); | |||||
} | |||||
@Override | |||||
public void doAfterDbRollback() { | |||||
afterRollback(bean); | |||||
} | |||||
}); | |||||
return bean; | |||||
} | |||||
/** | |||||
* 从页面获取待保存的bean | |||||
* | |||||
* @param pageDataSet | |||||
* @param data | |||||
* @return | |||||
*/ | |||||
protected T readBeanFromPage(PageDataset pageDataSet, SwMap data) { | |||||
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | |||||
if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name); | |||||
long id = data.readLong(table.getIdField()); | |||||
EntityDao<T> dao = DbEngine.getInstance().findDao(table.getName()); | |||||
T bean; | |||||
if (id <= 0L) { | |||||
bean = dao.createBean(); | |||||
bean.setIsNew(true); | |||||
//暂时不考虑list保存的情况 | |||||
bean.getData().putAll(data); | |||||
bean.setEntityId(DbEngine.getInstance().nextId()); | |||||
} else { | |||||
bean = dao.queryEntity(id); | |||||
if (bean == null) { | |||||
throw new BizException("没有找到待保存的记录:" + table.getName() + "." + id); | |||||
} | |||||
//暂时不考虑list保存的情况 | |||||
bean.getData().putAll(data); | |||||
bean.setIsNew(false); | |||||
} | |||||
return bean; | |||||
} | |||||
/** | |||||
* 保存校验 | |||||
* | |||||
* @param bean | |||||
*/ | |||||
protected void checkBean(T bean) { | |||||
ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); | |||||
for (ModelField field : table.getFields()) { | |||||
String value = bean.getStr(field.getName()); | |||||
//非空校验 | |||||
if (field.isNotNull() && StringUtils.isEmpty(value)) { | |||||
throw new BizException("字段不允许为空:" + field.getTitle()); | |||||
} | |||||
//长度校验 | |||||
if (StringUtils.isNotEmpty(value)) { | |||||
int len = SwEnum.DataType.instance.getByValue(field.getDataType()).dataLength; | |||||
if (len > 0 && StringUtil.getStrLenB(value) > len) { | |||||
throw new BizException("字段值超长:" + field.getTitle()); | |||||
} | |||||
} | |||||
} | |||||
//唯一键校验 | |||||
EntityDao<T> dao = DbEngine.getInstance().findDao(bean.getTableName()); | |||||
for (ModelIndex mi : table.getIndexes()) { | |||||
if (mi.isUnique()) { | |||||
dao.checkUnique(bean, 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); | |||||
} 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()); | |||||
dao.updateEntity(bean); | |||||
if (table.getType() == SwEnum.TableType.TYPE_TREE.value) { | |||||
List<T> listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean); | |||||
mapTreeBean.put(tableName, listTreeBean); | |||||
} | |||||
} | |||||
} | |||||
protected void afterCommit(T bean) { | |||||
final String tableName = bean.getTableName(); | |||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | |||||
if (table.isNeedCache()) { | |||||
AbstractCache<DefaultEntity> cache = CacheManager.getIntance().getCache(tableName); | |||||
List<T> listTreeBean = mapTreeBean.get(tableName); | |||||
//树型表,父亲改变了,要多处理下缓存;还有个东东:级次码 | |||||
if (listTreeBean != null && !listTreeBean.isEmpty()) { | |||||
for (DefaultEntity b : listTreeBean) { | |||||
cache.put(b); | |||||
} | |||||
} else { | |||||
cache.put(bean); | |||||
} | |||||
} | |||||
} | |||||
protected void afterRollback(T bean) { | |||||
final String tableName = bean.getTableName(); | |||||
ModelTable table = ModelTableCache.getInstance().getByName(tableName); | |||||
if (table.isNeedCache()) { | |||||
AbstractCache<T> cache = CacheManager.getIntance().getCache(tableName); | |||||
cache.reset(bean); | |||||
} | |||||
} | |||||
//将关联的值设上 | |||||
protected void setLinkValue(PageDataset pageDataSet, T bean, LCSingleSaveHandler.IGetValue iGetValue) { | |||||
ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName()); | |||||
for (PageDatasetFilter f : pageDataSet.filters) { | |||||
String v = bean.getStr(f.field); | |||||
//有值,就不管 | |||||
if (v != null && !v.equals(table.findField(f.field).getDefaultValue())) continue; | |||||
if (SwEnum.FilterType.CONST.value.equals(f.type)) {//常量 | |||||
bean.put(f.field, f.value); | |||||
} else if (SwEnum.FilterType.PARAM.value.equals(f.type)) {//参数 | |||||
bean.put(f.field, f.value); | |||||
} else if (SwEnum.FilterType.LINK.value.equals(f.type)) {//参数 | |||||
Object value = iGetValue.getValue(f); | |||||
if (value != null) { | |||||
bean.put(f.field, value); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
public interface IGetValue { | |||||
Object getValue(PageDatasetFilter f); | |||||
DefaultEntity bean = doSave(LCLC1Define.dsRCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCLC1Define.dsRCard, bean.getData())); | |||||
} | } | ||||
} | } |
@@ -14,11 +14,11 @@ import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; | |||||
*/ | */ | ||||
@SwService | @SwService | ||||
public class LCLC1Service extends DynPageService { | public class LCLC1Service extends DynPageService { | ||||
private final static String TYPE_MODEL_LIST = "modelList"; | |||||
private final static String TYPE_MODEL_ADD = "modelAdd"; | |||||
private final static String TYPE_MODEL_LOAD = "modelLoad"; | |||||
private final static String TYPE_MODEL_SAVE = "modelSave"; | |||||
private final static String TYPE_MODEL_DEL = "modelDel"; | |||||
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 | @Override | ||||
protected AbstractHandler createHandler(String type) { | protected AbstractHandler createHandler(String type) { | ||||
@@ -0,0 +1,14 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard.mastersub; | |||||
/** | |||||
* @Author:lip | |||||
* @Date : 2022/9/2 17:06 | |||||
*/ | |||||
public class LCMsDefine { | |||||
//列表主表数据集 | |||||
public static final String dsMList = "list"; | |||||
//卡片主表数据集 | |||||
public static final String dsMCard = "cardMaster"; | |||||
//卡片子表模型数据集 | |||||
public static final String dsSList = "listSub"; | |||||
} |
@@ -6,24 +6,45 @@ 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.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityDao; | import cc.smtweb.framework.core.db.EntityDao; | ||||
import cc.smtweb.framework.core.db.EntityHelper; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||||
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.exception.BizException; | import cc.smtweb.framework.core.exception.BizException; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; | |||||
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler; | |||||
import org.springframework.util.Assert; | import org.springframework.util.Assert; | ||||
import java.util.List; | |||||
/** | /** | ||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/8/28 20:40 | * @Date : 2022/8/28 20:40 | ||||
*/ | */ | ||||
public class LCMsDelHandler extends AbstractDynPageHandler { | |||||
public class LCMsDelHandler extends AbsDelHandler { | |||||
/** | |||||
* 列表删除 | |||||
* @return | |||||
*/ | |||||
public R lDel(){ | |||||
return del(); | |||||
} | |||||
/** | |||||
* 卡片删除 | |||||
* @return | |||||
*/ | |||||
public R cDel(){ | |||||
return del(); | |||||
} | |||||
/** | /** | ||||
* 删除指定数据集,入参{pageId, dataset, id} | * 删除指定数据集,入参{pageId, dataset, id} | ||||
* | * | ||||
* @return | * @return | ||||
*/ | */ | ||||
public R del() { | |||||
private R del() { | |||||
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 + ")!"); | ||||
SwMap props = form.getOpts().readMap("config").readMap("props"); | SwMap props = form.getOpts().readMap("config").readMap("props"); | ||||
@@ -37,14 +58,19 @@ public class LCMsDelHandler extends AbstractDynPageHandler { | |||||
Assert.isTrue(subTable!= null && !subForeignKey.equals("-1"),"未获取到子表配置"); | Assert.isTrue(subTable!= null && !subForeignKey.equals("-1"),"未获取到子表配置"); | ||||
// | // | ||||
DbEngine engine = DbEngine.getInstance(); | |||||
EntityDao<? extends DefaultEntity> masterDao = engine.findDao(masterTable.getName()); | |||||
EntityDao<? extends DefaultEntity> subDao = engine.findDao(subTable.getName()); | |||||
// | |||||
List<? extends DefaultEntity> delDetails = subDao.queryWhere(subForeignKey + " = ?", id); | |||||
checkDetails(delDetails); | |||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | DbEngine.getInstance().doTrans(new AbsDbWorker() { | ||||
@Override | @Override | ||||
public void work() { | public void work() { | ||||
DbEngine engine = DbEngine.getInstance(); | |||||
EntityDao masterDao = engine.findDao(masterTable.getName()); | |||||
EntityDao subDao = engine.findDao(subTable.getName()); | |||||
subDao.batchDelete(delDetails); | |||||
// | |||||
EntityHelper.checkExists(masterTable.getId(), id); | |||||
masterDao.deleteEntity(id); | masterDao.deleteEntity(id); | ||||
subDao.deleteEntity("where " + subForeignKey + " = ?", id); | |||||
} | } | ||||
@Override | @Override | ||||
@@ -61,4 +87,8 @@ public class LCMsDelHandler extends AbstractDynPageHandler { | |||||
}); | }); | ||||
return R.success(); | return R.success(); | ||||
} | } | ||||
protected void checkDetails(List<? extends DefaultEntity> details){ | |||||
details.forEach(item-> EntityHelper.checkExists(item.getModelTable().getId(), item.getEntityId())); | |||||
} | |||||
} | } |
@@ -1,11 +1,65 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard.mastersub; | package cc.smtweb.system.bpm.web.engine.model.listcard.mastersub; | ||||
import cc.smtweb.system.bpm.web.engine.model.listcard.normal.LCNormalLoadHandler; | |||||
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.abshandler.AbsLoadHandler; | |||||
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; | |||||
/** | /** | ||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/8/28 21:44 | * @Date : 2022/8/28 21:44 | ||||
*/ | */ | ||||
public class LCMsLoadHandler extends LCNormalLoadHandler { | |||||
public class LCMsLoadHandler extends AbsLoadHandler { | |||||
/** | |||||
* 主表新增 | |||||
* @return | |||||
*/ | |||||
public R mAdd() { | |||||
SwMap data = doAdd(LCMsDefine.dsMCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCMsDefine.dsMCard, data)); | |||||
} | |||||
/** | |||||
* 主表编辑 | |||||
* @return | |||||
*/ | |||||
public R mLoad() { | |||||
SwMap bean = doLoadCard(LCMsDefine.dsMCard); | |||||
return R.success(LCSingleHelper.buildRetData(LCMsDefine.dsMCard, bean)); | |||||
} | |||||
/** | |||||
* 主表列表加载 | |||||
* @return | |||||
*/ | |||||
public R mList(){ | |||||
DynRetBean list = doList(LCMsDefine.dsMList); | |||||
return R.success(list); | |||||
} | |||||
/** | |||||
* 子列表加载 | |||||
* @return | |||||
*/ | |||||
public R sList(){ | |||||
DynRetBean list = doList(LCMsDefine.dsSList); | |||||
return R.success(list); | |||||
} | |||||
/** | |||||
* 主列表分页数据 | |||||
* @return | |||||
*/ | |||||
public R getMTotal(){ | |||||
return doTotal(LCMsDefine.dsMList); | |||||
} | |||||
/** | |||||
* 子列表分页数据 | |||||
* @return | |||||
*/ | |||||
public R getSTotal(){ | |||||
return doTotal(LCMsDefine.dsSList); | |||||
} | |||||
} | } |
@@ -10,8 +10,9 @@ import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.exception.BizException; | 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.abshandler.AbsSaveHandler; | |||||
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; | import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; | ||||
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; | |||||
import org.springframework.util.Assert; | import org.springframework.util.Assert; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
@@ -21,32 +22,27 @@ import java.util.Set; | |||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/8/28 21:03 | * @Date : 2022/8/28 21:03 | ||||
*/ | */ | ||||
public class LCMsSaveHandler extends LCSingleSaveHandler { | |||||
private String cardMaster = "cardMaster"; | |||||
private String listSub = "listSub"; | |||||
public class LCMsSaveHandler extends AbsSaveHandler<DefaultEntity> { | |||||
/** | /** | ||||
* 保存指定数据集操作,入参:{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"); | |||||
//对应的数据集定义 | |||||
PageDataset masterDataSet = ModelUtils.findPageDatasetByName(this.datasets, LCMsDefine.dsMCard); | |||||
PageDataset subDataSet = ModelUtils.findPageDatasetByName(this.datasets, LCMsDefine.dsSList); | |||||
// | |||||
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 + "!"); | |||||
if (data == null) throw new BizException("没有收到待保存的的数据:" + LCMsDefine.dsMCard + "!"); | |||||
//获取子表关联字段 | |||||
String subForeignKey = form.getOpts().readMap("config").readMap("props").readString("subForeignKey","-1"); | String subForeignKey = form.getOpts().readMap("config").readMap("props").readString("subForeignKey","-1"); | ||||
Assert.isTrue(!subForeignKey.equals("-1"),"未获取到子表外键配置"); | Assert.isTrue(!subForeignKey.equals("-1"),"未获取到子表外键配置"); | ||||
//对应的数据集定义 | |||||
PageDataset masterDataSet = findDataset(cardMaster); | |||||
PageDataset subDataSet = findDataset(listSub); | |||||
Assert.isTrue(masterDataSet != null && subDataSet != null,"没有找到数据集"); | |||||
//读取待保存的bean | //读取待保存的bean | ||||
DefaultEntity masterBean = readBeanFromPage(masterDataSet, data.readMap(cardMaster).readMap("form")); | |||||
DefaultEntity masterBean = readBeanFromPage(masterDataSet, data.readMap(LCMsDefine.dsMCard).readMap("form")); | |||||
if (filter != null && masterBean.isNew()) { | if (filter != null && masterBean.isNew()) { | ||||
//有过滤条件,将关联的值设上 | //有过滤条件,将关联的值设上 | ||||
setLinkValue(masterDataSet, masterBean, f -> filter.get(f.name)); | setLinkValue(masterDataSet, masterBean, f -> filter.get(f.name)); | ||||
@@ -54,6 +50,7 @@ public class LCMsSaveHandler extends LCSingleSaveHandler { | |||||
// 读取子表数据 | // 读取子表数据 | ||||
SwMap details = params.readMap("details"); | SwMap details = params.readMap("details"); | ||||
Assert.notNull(details,"没有收到待保存的明细数据"); | Assert.notNull(details,"没有收到待保存的明细数据"); | ||||
// | |||||
ArrayList<DefaultEntity> inserted = new ArrayList<>(); | ArrayList<DefaultEntity> inserted = new ArrayList<>(); | ||||
ArrayList<DefaultEntity> updated = new ArrayList<>(); | ArrayList<DefaultEntity> updated = new ArrayList<>(); | ||||
details.readListMap("inserted").forEach(row -> { | details.readListMap("inserted").forEach(row -> { | ||||
@@ -101,37 +98,4 @@ public class LCMsSaveHandler extends LCSingleSaveHandler { | |||||
}); | }); | ||||
return R.success(LCSingleHelper.buildRetData(masterDataSet.name, masterBean.getData())); | return R.success(LCSingleHelper.buildRetData(masterDataSet.name, masterBean.getData())); | ||||
} | } | ||||
/** | |||||
* 从页面获取待保存的bean | |||||
* | |||||
* @param pageDataSet | |||||
* @param data | |||||
* @return | |||||
*/ | |||||
protected DefaultEntity readBeanFromPage(PageDataset pageDataSet, SwMap data) { | |||||
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); | |||||
if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name); | |||||
long id = data.readLong(table.getIdField()); | |||||
EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(table.getName()); | |||||
DefaultEntity bean; | |||||
if (id <= 0L) { | |||||
bean = dao.createBean(); | |||||
bean.setIsNew(true); | |||||
//暂时不考虑list保存的情况 | |||||
bean.getData().putAll(data); | |||||
} else { | |||||
bean = dao.queryEntity(id); | |||||
if (bean == null) { | |||||
throw new BizException("没有找到待保存的记录:" + table.getName() + "." + id); | |||||
} | |||||
//暂时不考虑list保存的情况 | |||||
bean.getData().putAll(data); | |||||
bean.setIsNew(false); | |||||
} | |||||
return bean; | |||||
} | |||||
} | } |
@@ -6,14 +6,14 @@ 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.mvc.service.AbstractHandler; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; | |||||
/** | /** | ||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/8/28 20:38 | * @Date : 2022/8/28 20:38 | ||||
*/ | */ | ||||
@SwService | @SwService | ||||
public class LCMsService extends LCSingleService { | |||||
public class LCMsService extends DynPageService { | |||||
private final static String TYPE_MODEL_LIST = "modelList"; | private final static String TYPE_MODEL_LIST = "modelList"; | ||||
private final static String TYPE_MODEL_ADD = "modelAdd"; | private final static String TYPE_MODEL_ADD = "modelAdd"; | ||||
private final static String TYPE_MODEL_LOAD = "modelLoad"; | private final static String TYPE_MODEL_LOAD = "modelLoad"; | ||||
@@ -42,26 +42,41 @@ public class LCMsService extends LCSingleService { | |||||
//读取 | //读取 | ||||
public R modelLoad(@SwBody SwMap params, UserSession us) { | public R modelLoad(@SwBody SwMap params, UserSession us) { | ||||
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCMsLoadHandler)handler).load()); | |||||
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCMsLoadHandler)handler).mLoad()); | |||||
} | } | ||||
//读取 | |||||
//新增 | |||||
public R modelAdd(@SwBody SwMap params, UserSession us) { | public R modelAdd(@SwBody SwMap params, UserSession us) { | ||||
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCMsLoadHandler)handler).add()); | |||||
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCMsLoadHandler)handler).mAdd()); | |||||
} | |||||
//列表删除 | |||||
public R modelLDel(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCMsDelHandler)handler).lDel()); | |||||
} | |||||
//卡片删除 | |||||
public R modelCDel(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCMsDelHandler)handler).cDel()); | |||||
} | |||||
//主表列表数据 | |||||
public R modelMList(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).mList()); | |||||
} | } | ||||
//删除 | |||||
public R modelDel(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCMsDelHandler)handler).del()); | |||||
//主表列表总记录数及合计栏 | |||||
public R modelMListTotal(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).getMTotal()); | |||||
} | } | ||||
//列表数据 | |||||
public R modelList(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).list()); | |||||
//子表列表数据 | |||||
public R modelSList(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).sList()); | |||||
} | } | ||||
//列表总记录数及合计栏 | |||||
public R modelListTotal(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).getTotal()); | |||||
//子表列表总记录数及合计栏 | |||||
public R modelSListTotal(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler)handler).getSTotal()); | |||||
} | } | ||||
} | } |
@@ -0,0 +1,12 @@ | |||||
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,58 +1,28 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard.normal; | package cc.smtweb.system.bpm.web.engine.model.listcard.normal; | ||||
import cc.smtweb.framework.core.cache.AbstractCache; | |||||
import cc.smtweb.framework.core.cache.CacheManager; | |||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.db.DbEngine; | |||||
import cc.smtweb.framework.core.db.EntityDao; | |||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||||
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||||
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.single.LCSingleDelHandler; | |||||
import org.springframework.util.Assert; | |||||
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler; | |||||
/** | /** | ||||
* Created by Akmm at 2022/4/21 17:53 | * Created by Akmm at 2022/4/21 17:53 | ||||
* 删除操作 | * 删除操作 | ||||
*/ | */ | ||||
public class LCNormalDelHandler extends LCSingleDelHandler { | |||||
public class LCNormalDelHandler extends AbsDelHandler { | |||||
/** | /** | ||||
* 删除指定数据集,入参{pageId, dataset, id} | |||||
* | |||||
* 通过列表删除 | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R del() { | |||||
long id = params.readLong("id"); | |||||
if (id == 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!"); | |||||
//数据集 | |||||
String dataSet = params.readString("dataset"); | |||||
PageDataset delDataSet = this.datasets.findByName(dataSet); | |||||
Assert.notNull(delDataSet, "未获取到数据集:" + dataSet); | |||||
// | |||||
checkBean(delDataSet, id); | |||||
// | |||||
DbEngine.getInstance().doTrans(new AbsDbWorker() { | |||||
@Override | |||||
public void work() { | |||||
ModelTable table = ModelTableCache.getInstance().get(delDataSet.masterTable); | |||||
if (table == null) throw new BizException("没有找到指定的的表定义:" + delDataSet.name + "!"); | |||||
EntityDao dao = DbEngine.getInstance().findDao(table.getName()); | |||||
dao.deleteEntity(id); | |||||
localDel(id, table); | |||||
} | |||||
public R listDel(){ | |||||
doDel(LCNormalDefine.dsList); | |||||
return R.success(); | |||||
} | |||||
@Override | |||||
public void doAfterDbCommit() { | |||||
ModelTable table = ModelTableCache.getInstance().get(delDataSet.masterTable); | |||||
if (table.isNeedCache()) { | |||||
AbstractCache cache = CacheManager.getIntance().getCache(table.getName()); | |||||
cache.remove(id); | |||||
} | |||||
afterCommit(id, table); | |||||
} | |||||
}); | |||||
/** | |||||
* 通过卡片删除 | |||||
* @return | |||||
*/ | |||||
public R cardDel(){ | |||||
doDel(LCNormalDefine.dsCard); | |||||
return R.success(); | return R.success(); | ||||
} | } | ||||
} | } |
@@ -2,54 +2,25 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.normal; | |||||
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.system.bpm.web.design.form.define.PageDataset; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageHelper; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler; | |||||
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.single.LCSingleHelper; | |||||
import org.springframework.util.Assert; | |||||
import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils; | |||||
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsLoadHandler; | |||||
/** | /** | ||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/8/29 14:37 | * @Date : 2022/8/29 14:37 | ||||
*/ | */ | ||||
public class LCNormalLoadHandler extends AbstractDynPageHandler { | |||||
public class LCNormalLoadHandler extends AbsLoadHandler { | |||||
//新增卡片操作,初始化定义的数据集 | //新增卡片操作,初始化定义的数据集 | ||||
public R add() { | public R add() { | ||||
String dataSet = params.readString("dataset"); | |||||
PageDataset addDataSet = this.datasets.findByName(dataSet); | |||||
Assert.notNull(addDataSet, "未获取到数据集:" + dataSet); | |||||
SwMap data; | |||||
//懒加载,给个空对象 | |||||
if (addDataSet.lazy) { | |||||
data = new SwMap(); | |||||
} else { | |||||
data = DynPageHelper.createBean(addDataSet); | |||||
} | |||||
return R.success(LCSingleHelper.buildRetData(addDataSet.name, data)); | |||||
SwMap data = doAdd(LCNormalDefine.dsCard); | |||||
return R.success(ModelUtils.buildRetData(LCNormalDefine.dsCard, data)); | |||||
} | } | ||||
public R load() { | public R load() { | ||||
//过滤条件 | |||||
SwMap filter = params.readMap("filter"); | |||||
//对应的数据集定义 | |||||
String dataSet = params.readString("dataset"); | |||||
PageDataset loadDataSet = this.datasets.findByName(dataSet); | |||||
Assert.notNull(loadDataSet, "未获取到数据集:" + dataSet); | |||||
SwMap data = provider.loadData(filter, loadDataSet); | |||||
return R.success(LCSingleHelper.buildRetData(loadDataSet.name, data)); | |||||
} | |||||
private DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) { | |||||
DynPageListHandler listHandler = new DynPageListHandler(form.getId(), filter, pageDataSet); | |||||
listHandler.init(params, us); | |||||
return listHandler; | |||||
SwMap data = doLoadCard(LCNormalDefine.dsCard); | |||||
return R.success(ModelUtils.buildRetData(LCNormalDefine.dsCard, data)); | |||||
} | } | ||||
/** | /** | ||||
@@ -57,17 +28,8 @@ public class LCNormalLoadHandler extends AbstractDynPageHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R list() { | public R list() { | ||||
//过滤条件 | |||||
SwMap filter = params.readMap("filter"); | |||||
//对应的数据集定义 | |||||
String dataSet = params.readString("dataset"); | |||||
PageDataset listDataSet = this.datasets.findByName(dataSet); | |||||
Assert.notNull(listDataSet, "未获取到数据集:" + dataSet); | |||||
DynRetBean bean = DynRetBean.createList(getListWorker(filter, listDataSet).buildListData()); | |||||
return R.success(bean); | |||||
DynRetBean dynRetBean = doList(LCNormalDefine.dsList); | |||||
return R.success(dynRetBean); | |||||
} | } | ||||
/** | /** | ||||
@@ -76,14 +38,6 @@ public class LCNormalLoadHandler extends AbstractDynPageHandler { | |||||
* @return | * @return | ||||
*/ | */ | ||||
public R getTotal() { | public R getTotal() { | ||||
//过滤条件 | |||||
SwMap filter = params.readMap("filter"); | |||||
//对应的数据集定义 | |||||
String dataSet = params.readString("dataset"); | |||||
PageDataset listDataSet = this.datasets.findByName(dataSet); | |||||
Assert.notNull(listDataSet, "未获取到数据集:" + dataSet); | |||||
return getListWorker(filter, listDataSet).getTotal(); | |||||
return doTotal(LCNormalDefine.dsList); | |||||
} | } | ||||
} | } |
@@ -0,0 +1,22 @@ | |||||
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())); | |||||
} | |||||
} |
@@ -6,14 +6,21 @@ 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.mvc.service.AbstractHandler; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService; | |||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; | |||||
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler; | |||||
/** | /** | ||||
* @Author:lip | * @Author:lip | ||||
* @Date : 2022/8/27 13:54 | * @Date : 2022/8/27 13:54 | ||||
*/ | */ | ||||
@SwService | @SwService | ||||
public class LCNormalService extends LCSingleService { | |||||
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 | @Override | ||||
protected AbstractHandler createHandler(String type) { | protected AbstractHandler createHandler(String type) { | ||||
switch (type) { | switch (type) { | ||||
@@ -21,15 +28,26 @@ public class LCNormalService extends LCSingleService { | |||||
case TYPE_MODEL_LOAD: | case TYPE_MODEL_LOAD: | ||||
case TYPE_MODEL_ADD: | case TYPE_MODEL_ADD: | ||||
return new LCNormalLoadHandler(); | return new LCNormalLoadHandler(); | ||||
case TYPE_MODEL_SAVE: | |||||
return new LCNormalSaveHandler(); | |||||
case TYPE_MODEL_DEL: | case TYPE_MODEL_DEL: | ||||
return new LCNormalDelHandler(); | return new LCNormalDelHandler(); | ||||
} | } | ||||
return super.createHandler(type); | 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 modelDel(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCNormalDelHandler)handler).del()); | |||||
//卡片删除 | |||||
public R modelCDel(@SwBody SwMap params, UserSession us) { | |||||
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCNormalDelHandler)handler).cardDel()); | |||||
} | } | ||||
//读取 | //读取 | ||||
@@ -19,11 +19,9 @@ import cc.smtweb.framework.core.util.StringUtil; | |||||
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.design.form.define.PageDatasetFilter; | import cc.smtweb.system.bpm.web.design.form.define.PageDatasetFilter; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; | import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.LinkedHashMap; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -70,9 +70,12 @@ | |||||
"text": true, | "text": true, | ||||
"link": false, | "link": false, | ||||
"linkType": "curr", | "linkType": "curr", | ||||
"nextAction": "", | |||||
"fxLink": "", | |||||
"fxLink_text": "" | |||||
<#if name?has_content && name?ends_with("List")> | |||||
"fxLink": "bpm.${name?replace("List","Card")}", | |||||
<#else> | |||||
"fxLink": "", | |||||
</#if> | |||||
"fxLink_text": "编辑卡片" | |||||
} | } | ||||
}, | }, | ||||
<#else > | <#else > | ||||
@@ -252,7 +252,6 @@ | |||||
"leftIcon": "plus", | "leftIcon": "plus", | ||||
"fxLink": "dialog:cardSubDialog", | "fxLink": "dialog:cardSubDialog", | ||||
"fxLink_text": "子表编辑卡片", | "fxLink_text": "子表编辑卡片", | ||||
"nextAction": "", | |||||
"preAction": "", | "preAction": "", | ||||
"dataset": "${layout.listSub[0].dataset}" | "dataset": "${layout.listSub[0].dataset}" | ||||
}, | }, | ||||
@@ -314,7 +313,6 @@ | |||||
"dataset": "${layout.listSub[0].dataset}", | "dataset": "${layout.listSub[0].dataset}", | ||||
"link": true, | "link": true, | ||||
"linkType": "", | "linkType": "", | ||||
"nextAction": "", | |||||
"fxLink": "" | "fxLink": "" | ||||
} | } | ||||
}, | }, | ||||
@@ -525,8 +523,7 @@ | |||||
"label": "关闭", | "label": "关闭", | ||||
"leftIcon": "close", | "leftIcon": "close", | ||||
"type": "", | "type": "", | ||||
"action": "button:closeDialog", | |||||
"nextAction": "button:search" | |||||
"action": "button:closeDialog" | |||||
}, | }, | ||||
"id": "id${newId()}" | "id": "id${newId()}" | ||||
} | } | ||||
@@ -550,4 +547,4 @@ | |||||
"widgetRef": [${widgetRef}], | "widgetRef": [${widgetRef}], | ||||
"vars": [] | "vars": [] | ||||
} | } | ||||
} | |||||
} |
@@ -213,7 +213,6 @@ | |||||
"type": "primary", | "type": "primary", | ||||
"leftIcon": "delete", | "leftIcon": "delete", | ||||
"action": "button:delCard", | "action": "button:delCard", | ||||
"nextAction":"button:loadList", | |||||
"link": true, | "link": true, | ||||
"text": false, | "text": false, | ||||
"dataset": "${assist.dataset}", | "dataset": "${assist.dataset}", | ||||
@@ -445,7 +444,6 @@ | |||||
"type": "danger", | "type": "danger", | ||||
"leftIcon": "delete", | "leftIcon": "delete", | ||||
"action": "button:delCard", | "action": "button:delCard", | ||||
"nextAction":"button:loadList", | |||||
"link": false, | "link": false, | ||||
"text": true, | "text": true, | ||||
"preAction": "" | "preAction": "" | ||||
@@ -583,8 +581,7 @@ | |||||
"label": "关闭", | "label": "关闭", | ||||
"leftIcon": "close", | "leftIcon": "close", | ||||
"type": "", | "type": "", | ||||
"action": "button:closeDialog", | |||||
"nextAction": "button:loadList" | |||||
"action": "button:closeDialog" | |||||
}, | }, | ||||
"id": "id${newId()}" | "id": "id${newId()}" | ||||
} | } | ||||
@@ -692,8 +689,7 @@ | |||||
"label": "关闭", | "label": "关闭", | ||||
"leftIcon": "close", | "leftIcon": "close", | ||||
"type": "", | "type": "", | ||||
"action": "button:closeDialog", | |||||
"nextAction": "button:loadList" | |||||
"action": "button:closeDialog" | |||||
}, | }, | ||||
"id": "id${newId()}" | "id": "id${newId()}" | ||||
} | } | ||||
@@ -387,7 +387,6 @@ | |||||
"type": "danger", | "type": "danger", | ||||
"leftIcon": "delete", | "leftIcon": "delete", | ||||
"action": "button:delCard", | "action": "button:delCard", | ||||
"nextAction":"button:loadList", | |||||
"link": false, | "link": false, | ||||
"text": true, | "text": true, | ||||
"preAction": "" | "preAction": "" | ||||
@@ -525,8 +524,7 @@ | |||||
"label": "关闭", | "label": "关闭", | ||||
"leftIcon": "close", | "leftIcon": "close", | ||||
"type": "", | "type": "", | ||||
"action": "button:closeDialog", | |||||
"nextAction": "button:loadList" | |||||
"action": "button:closeDialog" | |||||
}, | }, | ||||
"id": "id${newId()}" | "id": "id${newId()}" | ||||
} | } | ||||
@@ -68,8 +68,12 @@ | |||||
"action": "button:addCard", | "action": "button:addCard", | ||||
"link": false, | "link": false, | ||||
"linkType": "curr", | "linkType": "curr", | ||||
"fxLink": "", | |||||
"fxLink_text": "" | |||||
<#if name?has_content && name?ends_with("List")> | |||||
"fxLink": "bpm.${name?replace("List","Card")}", | |||||
<#else> | |||||
"fxLink": "", | |||||
</#if> | |||||
"fxLink_text": "编辑卡片" | |||||
}, | }, | ||||
"id": "id${newId()}", | "id": "id${newId()}", | ||||
"events": {} | "events": {} | ||||
@@ -150,8 +150,12 @@ | |||||
"action": "button:addCard", | "action": "button:addCard", | ||||
"link": false, | "link": false, | ||||
"linkType": "curr", | "linkType": "curr", | ||||
"fxLink": "", | |||||
"fxLink_text": "" | |||||
<#if name?has_content && name?ends_with("List")> | |||||
"fxLink": "bpm.${name?replace("List","Card")}", | |||||
<#else> | |||||
"fxLink": "", | |||||
</#if> | |||||
"fxLink_text": "编辑卡片" | |||||
}, | }, | ||||
"id": "id${newId()}", | "id": "id${newId()}", | ||||
"events": {} | "events": {} | ||||