From 5827136eecb68697cbf34f477caa4bd69bcfffb0 Mon Sep 17 00:00:00 2001 From: xyli Date: Mon, 13 Feb 2023 13:20:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9BaseDbCommonService.java?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0update=E7=9A=84?= =?UTF-8?q?=E9=87=8D=E8=BD=BD=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/h2db/BaseDbCommonService.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/main/java/mpms/service/h2db/BaseDbCommonService.java b/src/main/java/mpms/service/h2db/BaseDbCommonService.java index 2a00eb1..4afcbd6 100644 --- a/src/main/java/mpms/service/h2db/BaseDbCommonService.java +++ b/src/main/java/mpms/service/h2db/BaseDbCommonService.java @@ -155,5 +155,34 @@ public abstract class BaseDbCommonService { return 0; } + /** + * 修改数据 + * + * @param entity 要修改的数据 + * @param where 条件 + * @return 影响行数 + */ + public int update(Entity entity, Entity where) { + if (!DbConfig.getInstance().isInit()) { + // ignore + return 0; + } + Db db = Db.use(); + db.setWrapper((Character) null); + if (where.isEmpty()) { + throw new LinuxRuntimeException("没有更新条件"); + } + entity.setTableName(tableName); + where.setTableName(tableName); + try { + return db.update(entity, where); + } catch (SQLException e) { + throw new LinuxRuntimeException("数据库异常", e); + } + } + + + + } -- Gitee