diff --git a/yudao-admin-server/pom.xml b/yudao-admin-server/pom.xml
index 4785c31df..7b3bb7925 100644
--- a/yudao-admin-server/pom.xml
+++ b/yudao-admin-server/pom.xml
@@ -16,14 +16,62 @@
1.0.0
+ 2.4.4
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring.boot.version}
+ pom
+ import
+
+
+
+
cn.iocoder.boot
yudao-framework
${revision}
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ 2.4.4
+ test
+
+
+ asm
+ org.ow2.asm
+
+
+
+
+
+ com.h2database
+ h2
+ test
+
+
+
+ com.github.fppt
+ jedis-mock
+ 0.1.16
+ test
+
+
+
+ uk.co.jemos.podam
+ podam
+ 7.2.6.RELEASE
+ test
+
diff --git a/yudao-admin-server/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/impl/SysDictDataServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/impl/SysDictDataServiceImpl.java
index 1a2b19cc0..20ed72ebe 100644
--- a/yudao-admin-server/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/impl/SysDictDataServiceImpl.java
+++ b/yudao-admin-server/src/main/java/cn/iocoder/dashboard/modules/system/service/dict/impl/SysDictDataServiceImpl.java
@@ -250,7 +250,7 @@ public class SysDictDataServiceImpl implements SysDictDataService {
@Override
public List listDictDatasFromCache(String type) {
- return SysDictDataConvert.INSTANCE.convertList03(labelDictDataCache.row(type).values()));
+ return SysDictDataConvert.INSTANCE.convertList03(labelDictDataCache.row(type).values());
}
}
diff --git a/yudao-admin-server/src/main/resources/application-dev.yaml b/yudao-admin-server/src/main/resources/application-dev.yaml
index 526bf3d51..9963de739 100644
--- a/yudao-admin-server/src/main/resources/application-dev.yaml
+++ b/yudao-admin-server/src/main/resources/application-dev.yaml
@@ -99,6 +99,7 @@ apollo:
eagerLoad:
enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置
jdbc: # 自定义的 JDBC 配置项,用于数据库的地址
+ dao: cn.iocoder.dashboard.modules.infra.dal.mysql.config.InfConfigDAOImpl
url: ${spring.datasource.dynamic.datasource.master.url}
username: ${spring.datasource.dynamic.datasource.master.username}
password: ${spring.datasource.dynamic.datasource.master.password}
diff --git a/yudao-admin-server/src/main/resources/application-local.yaml b/yudao-admin-server/src/main/resources/application-local.yaml
index 8761a78a8..6e56f5071 100644
--- a/yudao-admin-server/src/main/resources/application-local.yaml
+++ b/yudao-admin-server/src/main/resources/application-local.yaml
@@ -99,6 +99,7 @@ apollo:
eagerLoad:
enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置
jdbc: # 自定义的 JDBC 配置项,用于数据库的地址
+ dao: cn.iocoder.dashboard.modules.infra.dal.mysql.config.InfConfigDAOImpl
url: ${spring.datasource.dynamic.datasource.master.url}
username: ${spring.datasource.dynamic.datasource.master.username}
password: ${spring.datasource.dynamic.datasource.master.password}
diff --git a/yudao-admin-server/src/test/java/cn/iocoder/dashboard/modules/system/service/auth/SysAuthServiceImplTest.java b/yudao-admin-server/src/test/java/cn/iocoder/dashboard/modules/system/service/auth/SysAuthServiceImplTest.java
index baccf727d..40b606836 100644
--- a/yudao-admin-server/src/test/java/cn/iocoder/dashboard/modules/system/service/auth/SysAuthServiceImplTest.java
+++ b/yudao-admin-server/src/test/java/cn/iocoder/dashboard/modules/system/service/auth/SysAuthServiceImplTest.java
@@ -66,7 +66,7 @@ public class SysAuthServiceImplTest extends BaseDbUnitTest {
// 准备参数
String username = randomString();
// mock 方法
- SysUserDO user = randomUserDO(o -> o.setUsername(username));
+ SysUserDO user = randomPojo(SysUserDO.class, o -> o.setUsername(username));
when(userService.getUserByUsername(eq(username))).thenReturn(user);
// 调用
@@ -93,7 +93,7 @@ public class SysAuthServiceImplTest extends BaseDbUnitTest {
// 准备参数
Long userId = randomLongId();
// mock 方法 01
- SysUserDO user = randomUserDO(o -> o.setId(userId));
+ SysUserDO user = randomPojo(SysUserDO.class, o -> o.setId(userId));
when(userService.getUser(eq(userId))).thenReturn(user);
// mock 方法 02
Set roleIds = randomSet(Long.class);
diff --git a/yudao-framework/src/main/java/cn/iocoder/dashboard/framework/apollo/internals/DBConfigRepository.java b/yudao-framework/src/main/java/cn/iocoder/dashboard/framework/apollo/internals/DBConfigRepository.java
index 3117769e6..acf2e1f48 100644
--- a/yudao-framework/src/main/java/cn/iocoder/dashboard/framework/apollo/internals/DBConfigRepository.java
+++ b/yudao-framework/src/main/java/cn/iocoder/dashboard/framework/apollo/internals/DBConfigRepository.java
@@ -1,9 +1,13 @@
package cn.iocoder.dashboard.framework.apollo.internals;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ClassUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.ReflectUtil;
import cn.iocoder.dashboard.framework.apollo.core.ConfigConsts;
import cn.iocoder.dashboard.framework.apollo.internals.dto.ConfigRespDTO;
import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
+import cn.iocoder.dashboard.util.object.ObjectUtils;
import com.ctrip.framework.apollo.Apollo;
import com.ctrip.framework.apollo.build.ApolloInjector;
import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
@@ -13,8 +17,10 @@ import com.ctrip.framework.apollo.internals.ConfigRepository;
import com.ctrip.framework.apollo.tracer.Tracer;
import com.ctrip.framework.apollo.util.ConfigUtil;
import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
+import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
+import java.lang.reflect.Constructor;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
@@ -58,9 +64,7 @@ public class DBConfigRepository extends AbstractConfigRepository {
this.propertiesFactory = ApolloInjector.getInstance(PropertiesFactory.class);
this.m_configUtil = ApolloInjector.getInstance(ConfigUtil.class);
// 初始化 DB
- cn.iocoder.dashboard.modules.infra.dal.mysql.config
- this.configFrameworkDAO = new InfConfigDAOImpl(System.getProperty(ConfigConsts.APOLLO_JDBC_URL),
- System.getProperty(ConfigConsts.APOLLO_JDBC_USERNAME), System.getProperty(ConfigConsts.APOLLO_JDBC_PASSWORD));
+ this.configFrameworkDAO = createConfigFrameworkDAO();
// 初始化加载
this.trySync();
@@ -71,6 +75,18 @@ public class DBConfigRepository extends AbstractConfigRepository {
INSTANCE = this;
}
+ @SneakyThrows
+ private static ConfigFrameworkDAO createConfigFrameworkDAO() {
+ String dao = System.getProperty(ConfigConsts.APOLLO_JDBC_DAO);
+ String url = System.getProperty(ConfigConsts.APOLLO_JDBC_URL);
+ String username = System.getProperty(ConfigConsts.APOLLO_JDBC_USERNAME);
+ String password = System.getProperty(ConfigConsts.APOLLO_JDBC_PASSWORD);
+ // 创建 DBConfigRepository 对象
+ Class extends ConfigFrameworkDAO> clazz = ClassUtil.loadClass(dao);
+ Constructor extends ConfigFrameworkDAO> constructor = ReflectUtil.getConstructor(clazz, String.class, String.class, String.class);
+ return constructor.newInstance(url, username, password);
+ }
+
/**
* 通知同步,
*/
diff --git a/yudao-framework/src/main/java/cn/iocoder/dashboard/framework/apollo/spring/boot/ApolloApplicationContextInitializer.java b/yudao-framework/src/main/java/cn/iocoder/dashboard/framework/apollo/spring/boot/ApolloApplicationContextInitializer.java
index 86498fe74..47af6b5d3 100644
--- a/yudao-framework/src/main/java/cn/iocoder/dashboard/framework/apollo/spring/boot/ApolloApplicationContextInitializer.java
+++ b/yudao-framework/src/main/java/cn/iocoder/dashboard/framework/apollo/spring/boot/ApolloApplicationContextInitializer.java
@@ -23,8 +23,8 @@ public class ApolloApplicationContextInitializer implements EnvironmentPostProce
private int order = DEFAULT_ORDER;
- private static final String[] APOLLO_SYSTEM_PROPERTIES = {ConfigConsts.APOLLO_JDBC_URL,
- ConfigConsts.APOLLO_JDBC_USERNAME, ConfigConsts.APOLLO_JDBC_PASSWORD};
+ private static final String[] APOLLO_SYSTEM_PROPERTIES = {ConfigConsts.APOLLO_JDBC_DAO,
+ ConfigConsts.APOLLO_JDBC_URL, ConfigConsts.APOLLO_JDBC_USERNAME, ConfigConsts.APOLLO_JDBC_PASSWORD};
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {