This commit is contained in:
淋雨一直走YH
2023-09-28 15:38:29 +08:00
commit 7bc57c75dc
1480 changed files with 144393 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<?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>mjkf.xinke</groupId>
<artifactId>mjkf-xinke-plugin-api</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>mjkf-xinke-plugin-dbs-api</artifactId>
<packaging>jar</packaging>
<description>多数据源插件api接口</description>
<dependencies>
<!-- 每个插件接口都要引入common -->
<dependency>
<groupId>mjkf.xinke</groupId>
<artifactId>mjkf-xinke-common</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,24 @@
package com.baomidou.dynamic.datasource.annotation;
import java.lang.annotation.*;
/**
* 数据源切换注解
*
*
* @date 2022/6/14 18:14
**/
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DS {
/**
* 组名称或特定的数据库名称或spring SPEL名称。
*
*
* @date 2022/6/14 18:15
**/
String value();
}

View File

@@ -0,0 +1,15 @@
package com.baomidou.dynamic.datasource.annotation;
import java.lang.annotation.*;
/**
*
*
*
* @date 2022/6/14 18:15
**/
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DSTransactional {
}

View File

@@ -0,0 +1,16 @@
package com.baomidou.dynamic.datasource.annotation;
import java.lang.annotation.*;
/**
* 主数据源
*
*
* @date 2022/6/14 18:15
**/
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@DS("master")
public @interface Master {
}

View File

@@ -0,0 +1,16 @@
package com.baomidou.dynamic.datasource.annotation;
import java.lang.annotation.*;
/**
* 从数据源
*
*
* @date 2022/6/14 18:15
**/
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@DS("slave")
public @interface Slave {
}

View File

@@ -0,0 +1,89 @@
package mjkf.xinke.dbs.api;
import cn.hutool.json.JSONObject;
import javax.sql.DataSource;
import java.util.List;
/**
* 数据源API接口
*
*
* @date 2022/3/8 16:30
**/
public interface DbsApi {
/**
* 获取默认的数据源名称
*
*
* @date 2022/3/11 14:25
**/
String getDefaultDataSourceName();
/**
* 获取当前正在使用的数据源名称
*
*
* @date 2022/3/8 16:31
**/
String getCurrentDataSourceName();
/**
* 获取当前正在使用的数据源ID
*
*
* @date 2022/8/5 14:01
**/
String getCurrentDataSourceId();
/**
* 获取当前正在使用的数据源
*
*
* @date 2022/3/8 16:31
**/
DataSource getCurrentDataSource();
/**
* 切换数据源
*
* @param name 数据源名称
*
* @date 2022/3/8 16:31
**/
void changeDataSource(String name);
/**
* 获取数据源详情
*
*
* @date 2022/7/11 17:53
*/
JSONObject dbsDetail(String dbsId);
/**
* 获取全部数据源列表
*
*
* @date 2022/7/11 17:53
*/
List<JSONObject> dbsSelector();
/**
* 获取租户数据源列表,只查询租户类型数据源
*
*
* @date 2022/7/11 17:53
*/
List<JSONObject> tenDbsSelector();
/**
* 根据表名称获取字段名称列表
*
*
* @date 2022/7/19 18:47
**/
List<String> tableColumns(String tableName);
}

View File

@@ -0,0 +1,17 @@
package mjkf.xinke.dbs.core.consts;
/**
* 数据源 plugin 常量
*
* @author : dongxiayu
* @date : 2022/3/8 10:14
*/
public interface DbsConstant {
/**
* 主数据源名称
*/
String MASTER_DATASOURCE_NAME = "MASTER";
}