Browse Source

废弃AbsDbWorker

4.0
郑根木 2 years ago
parent
commit
0103df9754
19 changed files with 53 additions and 64 deletions
  1. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcSaveHandler.java
  2. +4
    -8
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java
  3. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageDelHandler.java
  4. +3
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java
  5. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowProvider.java
  6. +9
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowTransHandler.java
  7. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsDelHandler.java
  8. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsSaveHandler.java
  9. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDelHandler.java
  10. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java
  11. +2
    -11
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleDelHandler.java
  12. +2
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleSaveHandler.java
  13. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/menuPlan/MenuPlanHandler.java
  14. +4
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/UserHandler.java
  15. +2
    -1
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/jdbc/AbsDbWorker.java
  16. +3
    -3
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/jdbc/IDbWorker.java
  17. +2
    -4
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractDelHandler.java
  18. +2
    -2
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractSaveHandler.java
  19. +3
    -4
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java

+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcSaveHandler.java View File

@@ -5,7 +5,7 @@ import cc.smtweb.framework.core.common.SwEnum;
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.cache.ModelTableCache; import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
import cc.smtweb.framework.core.db.vo.ModelField; import cc.smtweb.framework.core.db.vo.ModelField;
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;
@@ -65,7 +65,7 @@ public class ModelProcSaveHandler extends DefaultSaveHandler<ModelProc> {
throw new BizException("没有待保存的数据!"); throw new BizException("没有待保存的数据!");
} }
bean.setContent(data); bean.setContent(data);
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
EntityDao<ModelProc> dao = DbEngine.getInstance().findDao(tableName); EntityDao<ModelProc> dao = DbEngine.getInstance().findDao(tableName);


+ 4
- 8
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormSaveHandler.java View File

@@ -2,23 +2,19 @@ package cc.smtweb.system.bpm.web.design.form;


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.SwEnum;
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.cache.ModelTableCache; import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
import cc.smtweb.framework.core.db.vo.ModelField; import cc.smtweb.framework.core.db.vo.ModelField;
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.framework.core.mvc.service.DefaultSaveHandler; import cc.smtweb.framework.core.mvc.service.DefaultSaveHandler;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.system.bpm.web.design.form.model.ModelFactory; import cc.smtweb.system.bpm.web.design.form.model.ModelFactory;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;


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


/** /**
* Created by Akmm at 2022/5/9 17:05 * Created by Akmm at 2022/5/9 17:05
@@ -81,7 +77,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
throw new BizException("没有待保存的数据!"); throw new BizException("没有待保存的数据!");
} }
bean.setDataset(ModelFormHelper.buildSaveDataset(data)); bean.setDataset(ModelFormHelper.buildSaveDataset(data));
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(tableName); EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(tableName);
@@ -113,7 +109,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
throw new BizException("没有待保存的数据!"); throw new BizException("没有待保存的数据!");
} }
bean.setContent(ModelFormHelper.buildSaveModel(bean, data)); bean.setContent(ModelFormHelper.buildSaveModel(bean, data));
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(tableName); EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(tableName);
@@ -149,7 +145,7 @@ public class ModelFormSaveHandler extends DefaultSaveHandler<ModelForm> {
//先构建一次,防止有错 //先构建一次,防止有错
String ret = ModelFormHelper.buildReqModel(bean); String ret = ModelFormHelper.buildReqModel(bean);
// ModelFormHelper.buildSaveModelByTmpl(bean, templateId); // ModelFormHelper.buildSaveModelByTmpl(bean, templateId);
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(tableName); EntityDao<ModelForm> dao = DbEngine.getInstance().findDao(tableName);


+ 3
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageDelHandler.java View File

@@ -9,7 +9,7 @@ import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.EntityHelper; 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.impl.DefaultEntity;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
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;
@@ -39,7 +39,7 @@ public class DynPageDelHandler extends AbstractDynPageHandler {


checkBean(pageDataSet, id); checkBean(pageDataSet, id);


DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable);
@@ -107,7 +107,7 @@ public class DynPageDelHandler extends AbstractDynPageHandler {
info.ids.addAll(list); info.ids.addAll(list);
} }
} }
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
for (RemovableInfo info : mapRemovableInfo.values()) { for (RemovableInfo info : mapRemovableInfo.values()) {


+ 3
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java View File

@@ -9,12 +9,11 @@ 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.cache.ModelTableCache; 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.jdbc.IDbWorker;
import cc.smtweb.framework.core.db.vo.ModelField; import cc.smtweb.framework.core.db.vo.ModelField;
import cc.smtweb.framework.core.db.vo.ModelIndex; import cc.smtweb.framework.core.db.vo.ModelIndex;
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.framework.core.mvc.service.DefaultSaveHandler;
import cc.smtweb.framework.core.mvc.service.TreeHelper; import cc.smtweb.framework.core.mvc.service.TreeHelper;
import cc.smtweb.framework.core.util.StringUtil; 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;
@@ -55,7 +54,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
} }
checkBean(bean); checkBean(bean);


DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
saveBean(bean); saveBean(bean);
@@ -108,7 +107,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
} }
checkBean(bean); checkBean(bean);
} }
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
for (DefaultEntity bean : map.values()) { for (DefaultEntity bean : map.values()) {


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowProvider.java View File

@@ -62,7 +62,7 @@ public class FlowProvider extends AbstractCompProvider {
public List<Task> findBeforeTasks(String taskIds) { public List<Task> findBeforeTasks(String taskIds) {
EntityDao<Task> bdao = DbEngine.getInstance().findDao(Task.class); EntityDao<Task> bdao = DbEngine.getInstance().findDao(Task.class);
List<Task> list = bdao.queryEx(" t," + EntityHelper.getSchemaTableName(TaskRel.ENTITY_NAME) + " r " + List<Task> list = bdao.queryEx(" t," + EntityHelper.getSchemaTableName(TaskRel.ENTITY_NAME) + " r " +
"where t.task_id=r.trl_src_task_id and r.trl_dst_task_id in (" + taskIds + ")");
"where t.tsk_id=r.trl_src_task_id and r.trl_dst_task_id in (" + taskIds + ")");
if (CommUtil.isEmpty(list)) return new ArrayList<>(); if (CommUtil.isEmpty(list)) return new ArrayList<>();
return list; return list;
} }


+ 9
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowTransHandler.java View File

@@ -2,7 +2,9 @@ package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single;


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.DbEngine;
import cc.smtweb.framework.core.db.impl.DefaultEntity; import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
import cc.smtweb.framework.core.mvc.service.SwListData; import cc.smtweb.framework.core.mvc.service.SwListData;
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.dynPage.AbstractDynPageHandler; import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler;
@@ -10,11 +12,8 @@ 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.flow.entity.Task;
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper;


import java.util.List;

/** /**
* Created by Akmm at 2022-09-01 15:03 * Created by Akmm at 2022-09-01 15:03
* 流程流转 * 流程流转
@@ -54,7 +53,13 @@ public class FlowTransHandler<T extends DefaultEntity> extends AbstractDynPageHa


public R submit() { public R submit() {
load(); load();
flowInstance.submit(params.readString("comment"));
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override
public void work() {
flowInstance.submit(params.readString("comment"));
}
});

return R.success(buildRetData()); return R.success(buildRetData());
} }




+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsDelHandler.java View File

@@ -6,7 +6,7 @@ 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.EntityHelper;
import cc.smtweb.framework.core.db.cache.ModelTableCache; import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
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;
@@ -31,7 +31,7 @@ public abstract class AbsDelHandler extends AbstractDynPageHandler {
// //
checkBean(pageDataset, id); checkBean(pageDataset, id);
// //
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable); ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable);


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsSaveHandler.java View File

@@ -8,7 +8,7 @@ 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.cache.ModelTableCache; 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.jdbc.IDbWorker;
import cc.smtweb.framework.core.db.vo.ModelField; import cc.smtweb.framework.core.db.vo.ModelField;
import cc.smtweb.framework.core.db.vo.ModelIndex; import cc.smtweb.framework.core.db.vo.ModelIndex;
import cc.smtweb.framework.core.db.vo.ModelTable; import cc.smtweb.framework.core.db.vo.ModelTable;
@@ -51,7 +51,7 @@ public abstract class AbsSaveHandler <T extends DefaultEntity> extends AbstractD
} }
checkBean(bean); checkBean(bean);


DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
saveBean(bean); saveBean(bean);


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsDelHandler.java View File

@@ -9,7 +9,7 @@ import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.EntityHelper; 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.impl.DefaultEntity;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
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.model.listcard.abshandler.AbsDelHandler; import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler;
@@ -64,7 +64,7 @@ public class LCMsDelHandler extends AbsDelHandler {
// //
List<? extends DefaultEntity> delDetails = subDao.queryWhere(subForeignKey + " = ?", id); List<? extends DefaultEntity> delDetails = subDao.queryWhere(subForeignKey + " = ?", id);
checkDetails(delDetails); checkDetails(delDetails);
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
subDao.batchDelete(delDetails); subDao.batchDelete(delDetails);


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/mastersub/LCMsSaveHandler.java View File

@@ -6,7 +6,7 @@ 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.cache.ModelTableCache; 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.jdbc.IDbWorker;
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;
@@ -71,7 +71,7 @@ public class LCMsSaveHandler extends AbsSaveHandler<DefaultEntity> {
// //
checkBean(masterBean); checkBean(masterBean);


DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
saveBean(masterBean); saveBean(masterBean);


+ 2
- 11
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleDelHandler.java View File

@@ -3,24 +3,15 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.single;
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;
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.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.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.IDbWorker;
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.design.form.define.PageDatasetFilter;
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/** /**
* Created by Akmm at 2022/4/21 17:53 * Created by Akmm at 2022/4/21 17:53
@@ -40,7 +31,7 @@ public class LCSingleDelHandler extends AbstractDynPageHandler {


checkBean(pageDataSet, id); checkBean(pageDataSet, id);


DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable); ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable);


+ 2
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleSaveHandler.java View File

@@ -9,7 +9,7 @@ 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.cache.ModelTableCache; 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.jdbc.IDbWorker;
import cc.smtweb.framework.core.db.vo.ModelField; import cc.smtweb.framework.core.db.vo.ModelField;
import cc.smtweb.framework.core.db.vo.ModelIndex; import cc.smtweb.framework.core.db.vo.ModelIndex;
import cc.smtweb.framework.core.db.vo.ModelTable; import cc.smtweb.framework.core.db.vo.ModelTable;
@@ -52,7 +52,7 @@ public class LCSingleSaveHandler<T extends DefaultEntity> extends AbstractDynPag
} }
checkBean(bean); checkBean(bean);


DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
saveBean(bean); saveBean(bean);


+ 3
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/menuPlan/MenuPlanHandler.java View File

@@ -3,7 +3,7 @@ package cc.smtweb.system.bpm.web.sys.user.menuPlan;
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.DbEngine; import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
import cc.smtweb.framework.core.exception.BizException; import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.mvc.service.AbstractHandler; import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.mvc.service.SwListData; import cc.smtweb.framework.core.mvc.service.SwListData;
@@ -48,7 +48,7 @@ public class MenuPlanHandler {
menuPlanContent.saveItem(menuPlanItem, parent_id); menuPlanContent.saveItem(menuPlanItem, parent_id);
menuPlan.setContent(menuPlanContent.toContentStr()); menuPlan.setContent(menuPlanContent.toContentStr());


DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
DbEngine.getInstance().updateEntity(menuPlan, "smp_content"); DbEngine.getInstance().updateEntity(menuPlan, "smp_content");
@@ -79,7 +79,7 @@ public class MenuPlanHandler {
menuPlanContent.delItem(id); menuPlanContent.delItem(id);
menuPlan.setContent(menuPlanContent.toContentStr()); menuPlan.setContent(menuPlanContent.toContentStr());


DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
DbEngine.getInstance().updateEntity(menuPlan, "smp_content"); DbEngine.getInstance().updateEntity(menuPlan, "smp_content");


+ 4
- 4
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/user/user/UserHandler.java View File

@@ -6,7 +6,7 @@ import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine; import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao; import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.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.jdbc.IDbWorker;
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.framework.core.mvc.service.AbstractHandler; import cc.smtweb.framework.core.mvc.service.AbstractHandler;
@@ -178,7 +178,7 @@ public class UserHandler {
public R batchDelParty() { public R batchDelParty() {
Set<Long> idList = params.readLongSet("ids"); Set<Long> idList = params.readLongSet("ids");
Set<Long> roleIdList = UserRoleCache.getInstance().getByParty(idList); Set<Long> roleIdList = UserRoleCache.getInstance().getByParty(idList);
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
getUserPartyDao().deleteEntity(idList); getUserPartyDao().deleteEntity(idList);
@@ -198,7 +198,7 @@ public class UserHandler {
long id = params.readLong("id"); long id = params.readLong("id");
Set<Long> partyIds = UserPartyCache.getInstance().getIdByUser(id); Set<Long> partyIds = UserPartyCache.getInstance().getIdByUser(id);
Set<Long> roleIds = UserRoleCache.getInstance().getByParty(partyIds); Set<Long> roleIds = UserRoleCache.getInstance().getByParty(partyIds);
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
getUserDao().deleteEntity(id); getUserDao().deleteEntity(id);
@@ -224,7 +224,7 @@ public class UserHandler {
userList.forEach(user -> { userList.forEach(user -> {
user.setPwd(LoginHelper.encodePwd(user.getId(), SwConsts.DEF_PWD)); user.setPwd(LoginHelper.encodePwd(user.getId(), SwConsts.DEF_PWD));
}); });
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
DbEngine.getInstance().findDao(User.ENTITY_NAME).batchUpdateEntity(userList); DbEngine.getInstance().findDao(User.ENTITY_NAME).batchUpdateEntity(userList);


+ 2
- 1
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/jdbc/AbsDbWorker.java View File

@@ -2,8 +2,9 @@ package cc.smtweb.framework.core.db.jdbc;


/** /**
* Created by Akmm at 14-2-15 下午1:51 * Created by Akmm at 14-2-15 下午1:51
* 数据库事务操作方法类
* 数据库事务操作方法类,被废弃,用IDbWorker替代
*/ */
@Deprecated
public abstract class AbsDbWorker implements IDbWorker { public abstract class AbsDbWorker implements IDbWorker {
@Override @Override
public void doAfterDbCommit() {} public void doAfterDbCommit() {}


+ 3
- 3
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/db/jdbc/IDbWorker.java View File

@@ -5,11 +5,11 @@ package cc.smtweb.framework.core.db.jdbc;
* 数据库事务操作方法类 * 数据库事务操作方法类
*/ */
public interface IDbWorker { public interface IDbWorker {
public void work();
default void work(){}


//数据库提交完后的业务或缓存处理 //数据库提交完后的业务或缓存处理
public void doAfterDbCommit();
default void doAfterDbCommit(){}


//数据库回滚后的业务或缓存处理 //数据库回滚后的业务或缓存处理
public void doAfterDbRollback();
default void doAfterDbRollback(){}
} }

+ 2
- 4
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractDelHandler.java View File

@@ -2,7 +2,7 @@ package cc.smtweb.framework.core.mvc.service;


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.DbEngine;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;


/** /**
@@ -17,7 +17,7 @@ public abstract class AbstractDelHandler extends AbstractHandler{
id = readId(); id = readId();


checkValid(); checkValid();
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
delDb(); delDb();
@@ -25,13 +25,11 @@ public abstract class AbstractDelHandler extends AbstractHandler{


@Override @Override
public void doAfterDbCommit() { public void doAfterDbCommit() {
super.doAfterDbCommit();
saveSuccess(); saveSuccess();
} }


@Override @Override
public void doAfterDbRollback() { public void doAfterDbRollback() {
super.doAfterDbRollback();
saveFailed(); saveFailed();
} }
}); });


+ 2
- 2
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/AbstractSaveHandler.java View File

@@ -2,7 +2,7 @@ package cc.smtweb.framework.core.mvc.service;


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.DbEngine;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;


/** /**
@@ -29,7 +29,7 @@ public abstract class AbstractSaveHandler<T> extends AbstractHandler {
setNewId(); setNewId();
} }
checkValid(); checkValid();
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work(){ public void work(){
saveDb(); saveDb();


+ 3
- 4
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/mvc/service/DefaultSaveHandler.java View File

@@ -4,13 +4,12 @@ import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager; 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.SwEnum;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
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.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.cache.ModelTableCache; 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.ModelField;
import cc.smtweb.framework.core.db.vo.ModelIndex; import cc.smtweb.framework.core.db.vo.ModelIndex;
import cc.smtweb.framework.core.db.vo.ModelTable; import cc.smtweb.framework.core.db.vo.ModelTable;
@@ -46,7 +45,7 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractHandler
readFromPage(); readFromPage();
if (bean.getEntityId() <= 0L) bean.setEntityId(DbEngine.getInstance().nextId()); if (bean.getEntityId() <= 0L) bean.setEntityId(DbEngine.getInstance().nextId());
checkValid(); checkValid();
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work(){ public void work(){
saveDb(); saveDb();
@@ -159,7 +158,7 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractHandler
ModelField fieldParentId = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value); ModelField fieldParentId = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value);


bean.put(fieldParentId.getName(), parentId); bean.put(fieldParentId.getName(), parentId);
DbEngine.getInstance().doTrans(new AbsDbWorker() {
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override @Override
public void work() { public void work() {
listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean); listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean);


Loading…
Cancel
Save