@@ -54,6 +54,6 @@ public class FlowSingleService extends LCSingleService { | |||||
} | } | ||||
public R retake(@SwBody SwMap params, UserSession us) { | public R retake(@SwBody SwMap params, UserSession us) { | ||||
return flowHandler(params, us, FlowTransHandler::submit); | |||||
return flowHandler(params, us, FlowTransHandler::retake); | |||||
} | } | ||||
} | } |
@@ -4,6 +4,8 @@ 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.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.IDbSimpleWorker; | |||||
import cc.smtweb.framework.core.db.jdbc.IDbWorker; | 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; | ||||
@@ -53,19 +55,15 @@ public class FlowTransHandler<T extends DefaultEntity> extends AbstractDynPageHa | |||||
public R submit() { | public R submit() { | ||||
load(); | load(); | ||||
DbEngine.getInstance().doTrans(new IDbWorker() { | |||||
@Override | |||||
public void work() { | |||||
flowInstance.submit(params.readString("comment")); | |||||
} | |||||
}); | |||||
DbEngine.getInstance().doTrans(() -> flowInstance.submit(params.readString("comment"))); | |||||
return R.success(buildRetData()); | return R.success(buildRetData()); | ||||
} | } | ||||
public R retake() { | public R retake() { | ||||
load(); | load(); | ||||
flowInstance.retake(); | |||||
DbEngine.getInstance().doTrans(() -> flowInstance.retake()); | |||||
return R.success(buildRetData()); | return R.success(buildRetData()); | ||||
} | } | ||||
} | } |
@@ -0,0 +1,8 @@ | |||||
package cc.smtweb.framework.core.db.jdbc; | |||||
/** | |||||
* Created by Akmm at 2022-09-05 09:42 | |||||
*/ | |||||
public interface IDbSimpleWorker { | |||||
void work(); | |||||
} |
@@ -281,7 +281,7 @@ public class JdbcEngine { | |||||
* | * | ||||
* @param extractor 回调方法 | * @param extractor 回调方法 | ||||
* @return 事务是否成功,如果异常会也会事务回滚后再抛出异常 | * @return 事务是否成功,如果异常会也会事务回滚后再抛出异常 | ||||
*/ | |||||
*//* | |||||
public boolean doTrans(Supplier<Boolean> extractor) { | public boolean doTrans(Supplier<Boolean> extractor) { | ||||
try (JdbcTrans jdbcTrans = openTrans()) { | try (JdbcTrans jdbcTrans = openTrans()) { | ||||
boolean result = extractor.get(); | boolean result = extractor.get(); | ||||
@@ -292,7 +292,7 @@ public class JdbcEngine { | |||||
} | } | ||||
return false; | return false; | ||||
} | |||||
}*/ | |||||
public void beginTrans() { | public void beginTrans() { | ||||
Thread t = Thread.currentThread(); | Thread t = Thread.currentThread(); | ||||
@@ -346,6 +346,17 @@ public class JdbcEngine { | |||||
dbWorker.doAfterDbCommit(); | dbWorker.doAfterDbCommit(); | ||||
} | } | ||||
public void doTrans(IDbSimpleWorker dbWorker) throws SwException { | |||||
beginTrans(); | |||||
try { | |||||
dbWorker.work(); | |||||
commit(); | |||||
} catch (Exception e) { | |||||
rollback(e); | |||||
throw new SwException(e); | |||||
} | |||||
} | |||||
//独立事务 | //独立事务 | ||||
public void doTransSingle(IDbWorker worker) throws Exception { | public void doTransSingle(IDbWorker worker) throws Exception { | ||||
JdbcTrans jdbcTrans = openTrans(); | JdbcTrans jdbcTrans = openTrans(); | ||||