数据接入
parent
e2c17cf6c5
commit
f9f39497ab
|
@ -46,6 +46,9 @@ public class Result<T> implements Serializable {
|
|||
public static <T> Result<T> success (T data) {
|
||||
return restResult(data, SUCCESS, null);
|
||||
}
|
||||
public static <T> Result<T> success (String msg) {
|
||||
return restResult(null, SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> Result<T> success (T data, String msg) {
|
||||
return restResult(data, SUCCESS, msg);
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package com.muyu.common.core.utils;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 对象工具类
|
||||
* @Date 2023-10-9 下午 04:56
|
||||
*/
|
||||
public class ObjUtils {
|
||||
|
||||
/**
|
||||
* 兼容
|
||||
* CharSequence: 如果长度为零,则认为为空。
|
||||
* Array: 如果长度为零,则认为为空。
|
||||
* Collection: 如果元素为零,则认为为空。
|
||||
* Map: 如果键值映射为零,则认为为空。
|
||||
* @param o 对象
|
||||
* @return 如果对象具有受支持的类型并且为空或null,则为true,否则为false
|
||||
*/
|
||||
public static boolean notNull(Object o){
|
||||
return ObjectUtils.isNotEmpty(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断long类型不为0
|
||||
* @param val 值
|
||||
* @return 返回值不为0
|
||||
*/
|
||||
public static boolean notNull(Long val){
|
||||
return ObjectUtils.isNotEmpty(val) && val != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断Integer类型不为0
|
||||
* @param val 值
|
||||
* @return 返回值不为0
|
||||
*/
|
||||
public static boolean notNull(Integer val){
|
||||
return ObjectUtils.isNotEmpty(val) && val != 0;
|
||||
}
|
||||
/**
|
||||
* 判断BigDecimal类型不为0
|
||||
* @param val 值
|
||||
* @return 返回值不为0
|
||||
*/
|
||||
public static boolean notNull(BigDecimal val){
|
||||
return ObjectUtils.isNotEmpty(val) && val.doubleValue() == 0.00;
|
||||
}
|
||||
/**
|
||||
* 判断BigDecimal类型不为0
|
||||
* @param val 值
|
||||
* @return 返回值不为0
|
||||
*/
|
||||
public static boolean notChildNull(Object[] val){
|
||||
for (Object o : val) {
|
||||
if (!notNull(o)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-data-source</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-data-source-common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- 系统公共核心包 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-security</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,41 @@
|
|||
package com.muyu.data.source.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 接入类型对象 AccessType
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* on 2024/4/21
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("access_type")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "AccessType", description = "接入类型")
|
||||
public class AccessType extends BaseEntity{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 接入类型id */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "接入类型id", value = "接入类型id")
|
||||
private Long id;
|
||||
|
||||
/** 接入源名称 */
|
||||
@Excel(name = "接入类型名称")
|
||||
@ApiModelProperty(name = "接入类型名称", value = "接入类型名称")
|
||||
private String accessName;
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.muyu.data.source.domain.req;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 数据源对象 data_source
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DataSourceEditReq", description = "数据源")
|
||||
public class DataSourceEditReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 接入源名称 */
|
||||
@ApiModelProperty(name = "接入源名称", value = "接入源名称")
|
||||
private String accessSourceName;
|
||||
|
||||
/** 数据来源系统名称 */
|
||||
@ApiModelProperty(name = "数据来源系统名称", value = "数据来源系统名称")
|
||||
private String dataSourceSystemName;
|
||||
|
||||
/** 主机地址 */
|
||||
@ApiModelProperty(name = "主机地址", value = "主机地址")
|
||||
private String hostAddress;
|
||||
|
||||
/** 主机端口 */
|
||||
@ApiModelProperty(name = "主机端口", value = "主机端口")
|
||||
private String hostPort;
|
||||
|
||||
/** 数据连接类型ID */
|
||||
@ApiModelProperty(name = "数据连接类型ID", value = "数据连接类型ID")
|
||||
private Long dataAccessTypeId;
|
||||
|
||||
/** 数据库名称 */
|
||||
@ApiModelProperty(name = "数据库名称", value = "数据库名称")
|
||||
private String databaseName;
|
||||
|
||||
/** 数据连接参数 */
|
||||
@ApiModelProperty(name = "数据连接参数", value = "数据连接参数")
|
||||
private String dataConnectionParameter;
|
||||
|
||||
/** 初始连接数量 */
|
||||
@ApiModelProperty(name = "初始连接数量", value = "初始连接数量")
|
||||
private String initialQuantity;
|
||||
|
||||
/** 最大连接数量 */
|
||||
@ApiModelProperty(name = "最大连接数量", value = "最大连接数量")
|
||||
private String maximumQuantity;
|
||||
|
||||
/** 最大等待时间 */
|
||||
@ApiModelProperty(name = "最大等待时间", value = "最大等待时间")
|
||||
private Long maximumTime;
|
||||
|
||||
/** 最大等待次数 */
|
||||
@ApiModelProperty(name = "最大等待次数", value = "最大等待次数")
|
||||
private String maximumFrequency;
|
||||
|
||||
/** 数据库用户名 */
|
||||
@ApiModelProperty(name = "数据库用户名", value = "数据库用户名")
|
||||
private String databaseUserName;
|
||||
|
||||
/** 数据库用户密码 */
|
||||
@ApiModelProperty(name = "数据库用户密码", value = "数据库用户密码")
|
||||
private String databaseUserPassword;
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.muyu.data.source.domain.req;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 数据源对象 data_source
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DataSourceQueryReq", description = "数据源")
|
||||
public class DataSourceQueryReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 接入源名称 */
|
||||
@ApiModelProperty(name = "接入源名称", value = "接入源名称")
|
||||
private String accessSourceName;
|
||||
|
||||
/** 数据来源系统名称 */
|
||||
@ApiModelProperty(name = "数据来源系统名称", value = "数据来源系统名称")
|
||||
private String dataSourceSystemName;
|
||||
|
||||
/** 主机地址 */
|
||||
@ApiModelProperty(name = "主机地址", value = "主机地址")
|
||||
private String hostAddress;
|
||||
|
||||
/** 主机端口 */
|
||||
@ApiModelProperty(name = "主机端口", value = "主机端口")
|
||||
private String hostPort;
|
||||
|
||||
/** 数据连接类型ID */
|
||||
@ApiModelProperty(name = "数据连接类型ID", value = "数据连接类型ID")
|
||||
private Long dataAccessTypeId;
|
||||
|
||||
/** 数据库名称 */
|
||||
@ApiModelProperty(name = "数据库名称", value = "数据库名称")
|
||||
private String databaseName;
|
||||
|
||||
/** 数据连接参数 */
|
||||
@ApiModelProperty(name = "数据连接参数", value = "数据连接参数")
|
||||
private String dataConnectionParameter;
|
||||
|
||||
/** 初始连接数量 */
|
||||
@ApiModelProperty(name = "初始连接数量", value = "初始连接数量")
|
||||
private String initialQuantity;
|
||||
|
||||
/** 最大连接数量 */
|
||||
@ApiModelProperty(name = "最大连接数量", value = "最大连接数量")
|
||||
private String maximumQuantity;
|
||||
|
||||
/** 最大等待时间 */
|
||||
@ApiModelProperty(name = "最大等待时间", value = "最大等待时间")
|
||||
private Long maximumTime;
|
||||
|
||||
/** 最大等待次数 */
|
||||
@ApiModelProperty(name = "最大等待次数", value = "最大等待次数")
|
||||
private String maximumFrequency;
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package com.muyu.data.source.domain.req;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 数据源对象 data_source
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "DataSourceSaveReq", description = "数据源")
|
||||
public class DataSourceSaveReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 数据管理id */
|
||||
|
||||
@ApiModelProperty(name = "数据管理id", value = "数据管理id")
|
||||
private Long id;
|
||||
|
||||
/** 接入源名称 */
|
||||
|
||||
@ApiModelProperty(name = "接入源名称", value = "接入源名称")
|
||||
private String accessSourceName;
|
||||
|
||||
/** 数据来源系统名称 */
|
||||
|
||||
@ApiModelProperty(name = "数据来源系统名称", value = "数据来源系统名称")
|
||||
private String dataSourceSystemName;
|
||||
|
||||
/** 主机地址 */
|
||||
|
||||
@ApiModelProperty(name = "主机地址", value = "主机地址")
|
||||
private String hostAddress;
|
||||
|
||||
/** 主机端口 */
|
||||
|
||||
@ApiModelProperty(name = "主机端口", value = "主机端口")
|
||||
private String hostPort;
|
||||
|
||||
/** 数据连接类型ID */
|
||||
|
||||
@ApiModelProperty(name = "数据连接类型ID", value = "数据连接类型ID")
|
||||
private Long dataAccessTypeId;
|
||||
|
||||
/** 数据库名称 */
|
||||
|
||||
@ApiModelProperty(name = "数据库名称", value = "数据库名称")
|
||||
private String databaseName;
|
||||
|
||||
/** 数据连接参数 */
|
||||
|
||||
@ApiModelProperty(name = "数据连接参数", value = "数据连接参数")
|
||||
private String dataConnectionParameter;
|
||||
|
||||
/** 初始连接数量 */
|
||||
|
||||
@ApiModelProperty(name = "初始连接数量", value = "初始连接数量")
|
||||
private String initialQuantity;
|
||||
|
||||
/** 最大连接数量 */
|
||||
|
||||
@ApiModelProperty(name = "最大连接数量", value = "最大连接数量")
|
||||
private String maximumQuantity;
|
||||
|
||||
/** 最大等待时间 */
|
||||
|
||||
@ApiModelProperty(name = "最大等待时间", value = "最大等待时间")
|
||||
private Long maximumTime;
|
||||
|
||||
/** 最大等待次数 */
|
||||
|
||||
@ApiModelProperty(name = "最大等待次数", value = "最大等待次数")
|
||||
private String maximumFrequency;
|
||||
|
||||
/** 数据库用户名 */
|
||||
@ApiModelProperty(name = "数据库用户名", value = "数据库用户名")
|
||||
private String databaseUserName;
|
||||
|
||||
/** 数据库用户密码 */
|
||||
@ApiModelProperty(name = "数据库用户密码", value = "数据库用户密码")
|
||||
private String databaseUserPassword;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-data-source</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-data-source-remote</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,114 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-data-source</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-data-source-server</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-data-source-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.data.source;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* MuYuDataSourceApplication
|
||||
*
|
||||
* @author DeKangLiu
|
||||
* on 2024/4/20
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class MuYuDataSourceApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(MuYuDataSourceApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package com.muyu.data.source.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.data.source.domain.AccessType;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.data.source.domain.DataSource;
|
||||
import com.muyu.data.source.domain.req.DataSourceQueryReq;
|
||||
import com.muyu.data.source.domain.req.DataSourceSaveReq;
|
||||
import com.muyu.data.source.domain.req.DataSourceEditReq;
|
||||
import com.muyu.data.source.service.DataSourceService;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 数据源Controller
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
@Api(tags = "数据源")
|
||||
@RestController
|
||||
@RequestMapping("/source")
|
||||
public class DataSourceController extends BaseController {
|
||||
@Autowired
|
||||
private DataSourceService dataSourceService;
|
||||
|
||||
/**
|
||||
* 查询数据源列表
|
||||
*/
|
||||
@ApiOperation("获取数据源列表")
|
||||
@RequiresPermissions("dataSource:source:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<DataSource>> list(DataSourceQueryReq dataSourceQueryReq) {
|
||||
startPage();
|
||||
List<DataSource> list = dataSourceService.list(DataSource.queryBuild(dataSourceQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出数据源列表
|
||||
*/
|
||||
@ApiOperation("导出数据源列表")
|
||||
@RequiresPermissions("dataSource:source:export")
|
||||
@Log(title = "数据源", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, DataSource dataSource) {
|
||||
List<DataSource> list = dataSourceService.list(dataSource);
|
||||
ExcelUtil<DataSource> util = new ExcelUtil<DataSource>(DataSource.class);
|
||||
util.exportExcel(response, list, "数据源数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据源详细信息
|
||||
*/
|
||||
@ApiOperation("获取数据源详细信息")
|
||||
@RequiresPermissions("dataSource:source:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<DataSource> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(dataSourceService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据源
|
||||
*/
|
||||
@RequiresPermissions("dataSource:source:add")
|
||||
@Log(title = "数据源", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增数据源")
|
||||
public Result<String> add(@RequestBody DataSourceSaveReq dataSourceSaveReq) {
|
||||
return toAjax(dataSourceService.save(DataSource.saveBuild(dataSourceSaveReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据源
|
||||
*/
|
||||
@RequiresPermissions("dataSource:source:edit")
|
||||
@Log(title = "数据源", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改数据源")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody DataSourceEditReq dataSourceEditReq) {
|
||||
return toAjax(dataSourceService.updateById(DataSource.editBuild(id,dataSourceEditReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据源
|
||||
*/
|
||||
@RequiresPermissions("dataSource:source:remove")
|
||||
@Log(title = "数据源", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除数据源")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(dataSourceService.removeBatchByIds(ids));
|
||||
}
|
||||
/**
|
||||
* 查询接入类型列表
|
||||
*/
|
||||
@GetMapping("/findAccessType")
|
||||
public Result<List<AccessType>> findAccessType(){
|
||||
List<AccessType> accessTypeList=dataSourceService.findAccessType();
|
||||
return Result.success(accessTypeList);
|
||||
}
|
||||
@PostMapping("/testConnection")
|
||||
public Result testConnection(@RequestBody DataSourceSaveReq dataSourceSaveReq){
|
||||
return dataSourceService.testConnection(dataSourceSaveReq);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.data.source.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.data.source.domain.AccessType;
|
||||
import com.muyu.data.source.domain.DataSource;
|
||||
|
||||
/**
|
||||
* 数据源Mapper接口
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
public interface DataSourceMapper extends BaseMapper<DataSource> {
|
||||
|
||||
List<AccessType> findAccessType();
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.muyu.data.source.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.data.source.domain.AccessType;
|
||||
import com.muyu.data.source.domain.DataSource;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.data.source.domain.req.DataSourceSaveReq;
|
||||
|
||||
/**
|
||||
* 数据源Service接口
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
public interface DataSourceService extends IService<DataSource> {
|
||||
/**
|
||||
* 查询数据源列表
|
||||
*
|
||||
* @param dataSource 数据源
|
||||
* @return 数据源集合
|
||||
*/
|
||||
public List<DataSource> list(DataSource dataSource);
|
||||
|
||||
List<AccessType> findAccessType();
|
||||
|
||||
Result testConnection(DataSourceSaveReq dataSourceQueryReq);
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package com.muyu.data.source.service.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.data.source.domain.AccessType;
|
||||
import com.muyu.data.source.domain.req.DataSourceSaveReq;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.data.source.mapper.DataSourceMapper;
|
||||
import com.muyu.data.source.domain.DataSource;
|
||||
import com.muyu.data.source.service.DataSourceService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
/**
|
||||
* 数据源Service业务层处理
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-04-21
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSource> implements DataSourceService {
|
||||
@Autowired
|
||||
private DataSourceMapper dataSourceMapper;
|
||||
|
||||
/**
|
||||
* 查询数据源列表
|
||||
*
|
||||
* @param dataSource 数据源
|
||||
* @return 数据源
|
||||
*/
|
||||
@Override
|
||||
public List<DataSource> list(DataSource dataSource) {
|
||||
LambdaQueryWrapper<DataSource> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getAccessSourceName())){
|
||||
queryWrapper.like(DataSource::getAccessSourceName, dataSource.getAccessSourceName());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getDataSourceSystemName())){
|
||||
queryWrapper.like(DataSource::getDataSourceSystemName, dataSource.getDataSourceSystemName());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getHostAddress())){
|
||||
queryWrapper.eq(DataSource::getHostAddress, dataSource.getHostAddress());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getHostPort())){
|
||||
queryWrapper.eq(DataSource::getHostPort, dataSource.getHostPort());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getDataAccessTypeId())){
|
||||
queryWrapper.eq(DataSource::getDataAccessTypeId, dataSource.getDataAccessTypeId());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getDatabaseName())){
|
||||
queryWrapper.like(DataSource::getDatabaseName, dataSource.getDatabaseName());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getDataConnectionParameter())){
|
||||
queryWrapper.eq(DataSource::getDataConnectionParameter, dataSource.getDataConnectionParameter());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getInitialQuantity())){
|
||||
queryWrapper.eq(DataSource::getInitialQuantity, dataSource.getInitialQuantity());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getMaximumQuantity())){
|
||||
queryWrapper.eq(DataSource::getMaximumQuantity, dataSource.getMaximumQuantity());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (ObjUtils.notNull(dataSource.getMaximumFrequency())){
|
||||
queryWrapper.eq(DataSource::getMaximumFrequency, dataSource.getMaximumFrequency());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccessType> findAccessType() {
|
||||
return dataSourceMapper.findAccessType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result testConnection(DataSourceSaveReq dataSourceQueryReq) {
|
||||
String user = dataSourceQueryReq.getDatabaseUserName();
|
||||
String password = dataSourceQueryReq.getDatabaseUserPassword();
|
||||
String jdbcDriver = "com.mysql.cj.jdbc.Driver";
|
||||
String url = "jdbc:mysql://"+dataSourceQueryReq.getHostAddress()+":"+dataSourceQueryReq.getHostPort()+"/"+dataSourceQueryReq.getDatabaseName();
|
||||
try {
|
||||
Connection con = DriverManager.getConnection(url, user, password);
|
||||
if (con!=null){
|
||||
return Result.success("连接成功");
|
||||
}
|
||||
Statement stmt = con.createStatement();
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return Result.error("连接失败");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,29 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9527
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-data-source
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 115.159.81.159:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 115.159.81.159:8848
|
||||
namespace: f394dee0-fead-4010-8359-2955bacca31f
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.muyu.data.source.mapper: DEBUG
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/muyu-system"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.data.source.mapper.DataSourceMapper">
|
||||
|
||||
<resultMap type="com.muyu.data.source.domain.DataSource" id="DataSourceResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="accessSourceName" column="access_source_name" />
|
||||
<result property="dataSourceSystemName" column="data_source_system_name" />
|
||||
<result property="hostAddress" column="host_address" />
|
||||
<result property="hostPort" column="host_port" />
|
||||
<result property="dataAccessTypeId" column="data_access_type_id" />
|
||||
<result property="databaseName" column="database_name" />
|
||||
<result property="dataConnectionParameter" column="data_connection_parameter" />
|
||||
<result property="initialQuantity" column="initial_quantity" />
|
||||
<result property="maximumQuantity" column="maximum_quantity" />
|
||||
<result property="maximumTime" column="maximum_time" />
|
||||
<result property="maximumFrequency" column="maximum_frequency" />
|
||||
<result property="databaseUserName" column="database_user_name" />
|
||||
<result property="databaseUserPassword" column="database_user_password" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectDataSourceVo">
|
||||
select id, access_source_name, data_source_system_name, host_address, host_port, data_access_type_id, database_name, data_connection_parameter, initial_quantity, maximum_quantity, maximum_time, maximum_frequency, remark, create_by, create_time, update_by, update_time ,database_user_name ,database_user_password from data_source
|
||||
</sql>
|
||||
<select id="findAccessType" resultType="com.muyu.data.source.domain.AccessType">
|
||||
select * from access_type
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-data-source</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>muyu-data-source-common</module>
|
||||
<module>muyu-data-source-remote</module>
|
||||
<module>muyu-data-source-server</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -13,6 +13,7 @@
|
|||
<module>muyu-gen</module>
|
||||
<module>muyu-job</module>
|
||||
<module>muyu-file</module>
|
||||
<module>muyu-data-source</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>muyu-modules</artifactId>
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -35,12 +35,18 @@
|
|||
<minio.version>8.2.2</minio.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<transmittable-thread-local.version>2.14.3</transmittable-thread-local.version>
|
||||
<baomidou.version>3.3.1</baomidou.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
<version>${baomidou.version}</version>
|
||||
</dependency>
|
||||
<!-- SpringCloud 微服务 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
|
|
Loading…
Reference in New Issue