diff --git a/src/main/java/neatlogic/framework/rebuilddatabaseview/core/IRebuildDataBaseView.java b/src/main/java/neatlogic/framework/rebuilddatabaseview/core/IRebuildDataBaseView.java index 7b8d8cfd4e6a2be546318ce2854d071d6d79fa95..41779fd1e98356be4ce972849c385978f78a37a3 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 ec6f59120b0a76e8246c2b98ff2cc6816ee8bb22..163741824f4169e22b57362260f57d887d68ce79 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 0623bfbee47b1d7ee9203c9d48e361b4cfaa3658..facdbcaa9a5e449d45609863c1edce7b6a4ed8b7 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` - -