ather): 重构数据源配置功能

- 移除 DataSourceConfig 中的 beanName 字段,使用 name 字段替代
- 新增 DataSourceConfigDTO 类作为数据源配置的传输对象
- 实现 DataSourceConfigConvert 接口,用于 DTO 和 DruidDataSource 之间的转换
- 更新 DataSourceConfigService 接口,使用 DTO 作为参数- 重构 DataSourceConfigServiceImpl 中的 add 方法,使用 DTO 和转换器
- 更新应用配置,移除全局的 driverClassName 配置- 新增 SQL Server 数据源支持
dev
1iyc 1 week ago
parent 4bd634fa63
commit e471b56281

@ -31,6 +31,8 @@
<poi.version>4.1.2</poi.version>
<velocity.version>2.3</velocity.version>
<jwt.version>0.9.1</jwt.version>
<mapstruct.version>1.6.2</mapstruct.version>
<lombok.version>1.18.22</lombok.version>
</properties>
<!-- 依赖声明 -->
@ -196,6 +198,13 @@
<version>${sync.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -222,6 +231,19 @@
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<parameters>true</parameters>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>

@ -43,6 +43,11 @@
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<!-- 核心模块-->
<dependency>
<groupId>com.lyr</groupId>
@ -67,6 +72,7 @@
<artifactId>sync-gather</artifactId>
</dependency>
</dependencies>

@ -5,13 +5,12 @@ spring:
port: 6379
database: 1
password: eGDiN3RRhRNzrzjd
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${spring.redis.host}:3306/sync-data?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: K2bfP8rzG62ZSJGN
@ -19,6 +18,7 @@ spring:
slave:
# 从数据源开关/默认关闭
enabled: false
driverClassName:
url:
username:
password:

@ -5,13 +5,12 @@ spring:
port: 6379
database: 1
password: eGDiN3RRhRNzrzjd
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${spring.redis.host}:3306/sync-data?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: K2bfP8rzG62ZSJGN
@ -19,6 +18,7 @@ spring:
slave:
# 从数据源开关/默认关闭
enabled: false
driverClassName:
url:
username:
password:

@ -114,6 +114,24 @@
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.2.1-jre</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,31 @@
package com.lyr.common.core.domain;
import com.google.common.collect.ImmutableMap;
import com.lyr.common.constant.HttpStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.HashMap;
import java.util.Map;
/**
*
*
* @author liyc
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ServiceResult extends HashMap<String, Object> {
private Integer code;
private String message;
private Map data;
public static ServiceResult success(String name) {
ImmutableMap<Object, Object> data1 = ImmutableMap.of();
return new ServiceResult(HttpStatus.SUCCESS, name, data1);
}
}

@ -36,6 +36,15 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
return (T) beanFactory.getBean(name);
}
public static <T> T getBeanOfNull(String name) throws BeansException {
try {
return (T) beanFactory.getBean(name);
} catch (BeansException e) {
}
return null;
}
/**
* requiredType
*

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save