diff --git a/common/src/main/java/ink/wgink/common/startup/CommonStartup.java b/common/src/main/java/ink/wgink/common/startup/CommonStartup.java index d680f9e8..127d8063 100644 --- a/common/src/main/java/ink/wgink/common/startup/CommonStartup.java +++ b/common/src/main/java/ink/wgink/common/startup/CommonStartup.java @@ -5,6 +5,7 @@ import ink.wgink.common.manager.env.EnvManager; import ink.wgink.interfaces.init.IInitBaseMenu; import ink.wgink.interfaces.init.IInitBaseTable; import ink.wgink.interfaces.init.IInitBaseUser; +import ink.wgink.interfaces.init.IInitMongoData; import ink.wgink.properties.ServerProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; @@ -43,28 +44,52 @@ public class CommonStartup implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { - if (serverProperties.getInit() == null || serverProperties.getInit().getTable()) { - // 建表 - Map initBaseTableMap = applicationContext.getBeansOfType(IInitBaseTable.class); - for (Map.Entry kv : initBaseTableMap.entrySet()) { - kv.getValue().createTable(); - } - } - if (serverProperties.getInit() == null || serverProperties.getInit().getMenu()) { - // 初始化菜单 - if (initBaseMenu != null) { - initBaseMenu.init(); - } - } - if (serverProperties.getInit() == null || serverProperties.getInit().getUser()) { - // 创建用户 - if (initBaseUser != null) { - initBaseUser.init(); - } - } + serverInit(); + initManager(); + initMongoData(); + } + + /** + * 初始化 mongo 数据 + */ + private void initMongoData() { + Map initMongoDataMap = applicationContext.getBeansOfType(IInitMongoData.class); + initMongoDataMap.forEach((key, value) -> value.init()); + } + + /** + * 初始化管理器 + */ + private void initManager() { // 初始化环境变量 EnvManager envManager = EnvManager.getInstance(); envManager.setEnvDao(envDao); envManager.refreshEnv(); } + + /** + * 服务初始化 + */ + private void serverInit() { + boolean isInitTable = serverProperties.getInit() == null || serverProperties.getInit().getTable(); + boolean isInitMenu = serverProperties.getInit() == null || serverProperties.getInit().getMenu(); + boolean isInitUser = serverProperties.getInit() == null || serverProperties.getInit().getUser(); + if (isInitTable) { + // 建表 + Map initBaseTableMap = applicationContext.getBeansOfType(IInitBaseTable.class); + initBaseTableMap.forEach((key, value) -> value.createTable()); + } + if (isInitMenu) { + // 初始化菜单 + if (initBaseMenu != null) { + initBaseMenu.init(); + } + } + if (isInitUser) { + // 创建用户 + if (initBaseUser != null) { + initBaseUser.init(); + } + } + } } diff --git a/pom.xml b/pom.xml index e49a516a..3dad7742 100644 --- a/pom.xml +++ b/pom.xml @@ -48,14 +48,15 @@ basic-abstract module-examine mongo-login + mongo-menu pom 1.8 - 5.2.20.RELEASE + 5.3.20 5.2.9.RELEASE - 2.3.3.RELEASE + 2.7.0 1.2.25 2.0.2 20210307 @@ -100,11 +101,8 @@ 6.0.0 1.10 8.2.1 - 3.2.5 + 3.4.0 2.5.5 - 2.3.31 - 2.8.5 - 1.14.3 @@ -206,6 +204,14 @@ + + + com.fasterxml.jackson.core + jackson-databind + 2.13.3 + + + com.alibaba @@ -545,7 +551,7 @@ org.freemarker freemarker - ${freemarker.version} + 2.3.31 @@ -553,7 +559,7 @@ com.google.code.gson gson - ${gson.version} + 2.8.5 @@ -561,9 +567,17 @@ org.jsoup jsoup - ${jsoup.version} + 1.14.3 + + + + org.apache.xmlgraphics + xmlgraphics-commons + 2.7 + +