From f586113ab82adaebdd3dfbb2d07f6f0a833d85ec Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Thu, 13 Feb 2025 18:02:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E9=87=8D=E5=BB=BA?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E5=A4=B1=E8=B4=A5=E4=BA=86=E5=8D=B4=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1352076393676800]重建视图失败了却提示成功 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1352076393676800 --- .../core/IRebuildDataBaseView.java | 12 +- .../core/RebuildDataBaseViewManager.java | 28 ++++- .../restful/dao/mapper/ApiAuditMapper.xml | 15 +-- .../handler/MatrixViewRebuildHandler.java | 105 +++++++++++++----- .../CheckUpdateDataBaseViewHandler.java | 2 +- .../tenantinit/DataBaseViewInitHandler.java | 40 +++++++ 6 files changed, 156 insertions(+), 46 deletions(-) create mode 100644 src/main/java/neatlogic/module/framework/tenantinit/DataBaseViewInitHandler.java diff --git a/src/main/java/neatlogic/framework/rebuilddatabaseview/core/IRebuildDataBaseView.java b/src/main/java/neatlogic/framework/rebuilddatabaseview/core/IRebuildDataBaseView.java index 7b8d8cfd4..41779fd1e 100644 --- a/src/main/java/neatlogic/framework/rebuilddatabaseview/core/IRebuildDataBaseView.java +++ b/src/main/java/neatlogic/framework/rebuilddatabaseview/core/IRebuildDataBaseView.java @@ -27,7 +27,17 @@ public interface IRebuildDataBaseView { String getDescription(); - List execute(); + /** + * 只有视图不存在时才创建视图 + * @return + */ + List createViewIfNotExists(); + + /** + * 如果视图存在则删除,重新创建视图 + * @return + */ + List createOrReplaceView(); int getSort(); } diff --git a/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java b/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java index ec6f59120..163741824 100644 --- a/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java +++ b/src/main/java/neatlogic/framework/rebuilddatabaseview/core/RebuildDataBaseViewManager.java @@ -46,8 +46,32 @@ public class RebuildDataBaseViewManager extends ModuleInitializedListenerBase { moduleGroup2HandlerListMap.computeIfAbsent(context.getGroup(), key -> new ArrayList<>()).add(bean); } } + /** + * 只有视图不存在时才创建视图 + * @return + */ + public static List createViewIfNotExists() { + List resultList = new ArrayList<>(); + List list = new ArrayList<>(); + List activeModuleGroupList = TenantContext.get().getActiveModuleGroupList(); + for (ModuleGroupVo moduleGroupVo : activeModuleGroupList) { + List handlerList = moduleGroup2HandlerListMap.get(moduleGroupVo.getGroup()); + if (CollectionUtils.isNotEmpty(handlerList)) { + list.addAll(handlerList); + } + } + list.sort(Comparator.comparing(IRebuildDataBaseView::getSort)); + for (IRebuildDataBaseView rebuildDataBaseView : list) { + resultList.addAll(rebuildDataBaseView.createViewIfNotExists()); + } + return resultList; + } - public static List execute() { + /** + * 如果视图存在则删除,重新创建视图 + * @return + */ + public static List createOrReplaceView() { List resultList = new ArrayList<>(); List list = new ArrayList<>(); List activeModuleGroupList = TenantContext.get().getActiveModuleGroupList(); @@ -59,7 +83,7 @@ public class RebuildDataBaseViewManager extends ModuleInitializedListenerBase { } list.sort(Comparator.comparing(IRebuildDataBaseView::getSort)); for (IRebuildDataBaseView rebuildDataBaseView : list) { - List viewStatusInfoList = rebuildDataBaseView.execute(); + List viewStatusInfoList = rebuildDataBaseView.createOrReplaceView(); EscapeTransactionJob.State s = new EscapeTransactionJob(() -> { for (ViewStatusInfo viewStatusInfo : viewStatusInfoList) { if (Objects.equals(viewStatusInfo.getStatus(), ViewStatusInfo.Status.FAILURE.toString())) { diff --git a/src/main/java/neatlogic/framework/restful/dao/mapper/ApiAuditMapper.xml b/src/main/java/neatlogic/framework/restful/dao/mapper/ApiAuditMapper.xml index 0623bfbee..facdbcaa9 100644 --- a/src/main/java/neatlogic/framework/restful/dao/mapper/ApiAuditMapper.xml +++ b/src/main/java/neatlogic/framework/restful/dao/mapper/ApiAuditMapper.xml @@ -152,14 +152,13 @@ along with this program. If not, see .--> useCache="false"> select COUNT(1) - from `api_audit` LEFT JOIN `user` - on `api_audit`.`user_uuid` = `user`.`uuid` + from `api_audit` - and `api_audit`.`user_uuid` = #{userUuid} + and `user_uuid` = #{userUuid} - AND `api_audit`.`token` IN + AND `token` IN #{token} @@ -174,14 +173,6 @@ along with this program. If not, see .--> and `ip` LIKE CONCAT('%', #{ip}, '%') - - - order by `start_time` desc - - - order by `start_time` - -