Parcourir la source

shardingjdbc 整合测试

xucaiqin il y a 2 ans
Parent
commit
ddd047be86

+ 1 - 0
pom.xml

@@ -39,6 +39,7 @@
         <pagehelper.version>5.3.2</pagehelper.version>
         <pagehelper-spring-boot-starter.version>1.4.7</pagehelper-spring-boot-starter.version>
         <junit.version>4.13.2</junit.version>
+        <pagehelper-spring-boot-starter.version>1.4.7</pagehelper-spring-boot-starter.version>
     </properties>
     <dependencyManagement>
         <dependencies>

+ 1 - 4
sckw-common/sckw-common-core/src/main/java/com/sckw/core/aspect/DaoAspect.java

@@ -4,15 +4,12 @@ import com.sckw.core.model.auth.context.LoginUserHolder;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.IdWorker;
-import com.sckw.core.utils.StringUtils;
 import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Pointcut;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.stereotype.Component;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
+
 import java.util.Date;
 import java.util.Objects;
 

+ 0 - 1
sckw-common/sckw-common-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -1 +0,0 @@
-com.sckw.core.aspect.DaoAspect

+ 20 - 31
sckw-common/sckw-common-datasource/pom.xml

@@ -72,36 +72,25 @@
         </dependency>
     </dependencies>
     <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-shade-plugin</artifactId>
-                <version>3.2.4</version>
-                <configuration>
-                    <createDependencyReducedPom>false</createDependencyReducedPom>
-                    <filters>
-                        <filter>
-                            <artifact>*:*</artifact>
-                            <excludes>
-                                <exclude>META-INF/services/**</exclude>
-                            </excludes>
-                        </filter>
-                    </filters>
-                    <transformers>
-                        <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
-                            <resource>META-INF/services/*</resource>
-                        </transformer>
-                    </transformers>
-                </configuration>
-                <executions>
-                    <execution>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>shade</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
+        <resources>
+            <resource>
+                <!-- xml放在java目录下-->
+                <directory>src/main/java</directory>
+                <includes>
+                    <include>**/*.xml</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*.properties</include>
+                    <!-- 配置一下yml文件 -->
+                    <include>**/*.yml</include>
+                    <include>**/*.xml</include>
+                    <include>META-INF/**</include>
+                </includes>
+                <filtering>false</filtering>
+            </resource>
+        </resources>
     </build>
 </project>

+ 74 - 0
sckw-common/sckw-common-datasource/src/main/java/com/sckw/datasource/MyShardingAlgorithm.java

@@ -0,0 +1,74 @@
+package com.sckw.datasource;
+
+import com.google.common.base.Preconditions;
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.infra.util.expr.InlineExpressionParser;
+import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
+import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Properties;
+
+/**
+ * @Author xucaiqin
+ * @date 2023-06-19 09:38:18
+ */
+@Slf4j
+public class MyShardingAlgorithm implements ComplexKeysShardingAlgorithm<Comparable<?>> {
+    private static final String ALGORITHM_EXPRESSION_KEY = "algorithm-expression";
+
+    private static final String SHARING_COLUMNS_KEY = "sharding-columns";
+
+    private static final String ALLOW_RANGE_QUERY_KEY = "allow-range-query-with-inline-sharding";
+
+    @Getter
+    private Properties props;
+
+    private String algorithmExpression;
+
+    private Collection<String> shardingColumns;
+
+    private boolean allowRangeQuery;
+
+    @Override
+    public void init(final Properties props) {
+        this.props = props;
+        algorithmExpression = getAlgorithmExpression(props);
+        shardingColumns = getShardingColumns(props);
+        allowRangeQuery = getAllowRangeQuery(props);
+    }
+
+    private String getAlgorithmExpression(final Properties props) {
+        String algorithmExpression = props.getProperty(ALGORITHM_EXPRESSION_KEY);
+        Preconditions.checkNotNull(algorithmExpression, "Inline sharding algorithm expression can not be null.");
+        return InlineExpressionParser.handlePlaceHolder(algorithmExpression.trim());
+    }
+
+    private Collection<String> getShardingColumns(final Properties props) {
+        String shardingColumns = props.getProperty(SHARING_COLUMNS_KEY, "");
+        return shardingColumns.isEmpty() ? Collections.emptyList() : Arrays.asList(shardingColumns.split(","));
+    }
+
+    private boolean getAllowRangeQuery(final Properties props) {
+        return Boolean.parseBoolean(props.getOrDefault(ALLOW_RANGE_QUERY_KEY, Boolean.FALSE.toString()).toString());
+    }
+
+    @Override
+    public Collection<String> doSharding(Collection<String> availableTargetNames, ComplexKeysShardingValue<Comparable<?>> shardingValue) {
+        log.info("availableTargetNames:{} 2:{}", availableTargetNames, shardingValue);
+        return null;
+    }
+
+    @Override
+    public Properties getProps() {
+        return null;
+    }
+
+    @Override
+    public String getType() {
+        return "COMPLEX-DB";
+    }
+}

+ 97 - 24
sckw-common/sckw-common-datasource/src/main/java/com/sckw/datasource/config/ShardingJdbcAutoConfig.java

@@ -10,6 +10,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
 import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
+import org.apache.shardingsphere.infra.metadata.database.schema.util.SchemaMetaDataUtil;
 import org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlModeConfiguration;
 import org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlPersistRepositoryConfiguration;
 import org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration;
@@ -18,6 +19,8 @@ import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
 import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
+import org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
+import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
@@ -84,7 +87,7 @@ public class ShardingJdbcAutoConfig {
         Map<String, DataSource> dataSourceMap = createDataSources(shardingJdbcProperties);
         /*构建属性配置*/
         Properties props = shardingJdbcProperties.getProps();
-        return ShardingSphereDataSourceFactory.createDataSource(/*shardingJdbcProperties.getDatabaseName(),*/ modeConfiguration, dataSourceMap, Collections.singleton(createShardingRuleConfiguration(shardingJdbcProperties)), props);
+        return ShardingSphereDataSourceFactory.createDataSource(shardingJdbcProperties.getDatabaseName(), modeConfiguration, dataSourceMap, Collections.singleton(createShardingRuleConfiguration(shardingJdbcProperties)), props);
     }
 
     /**
@@ -92,45 +95,115 @@ public class ShardingJdbcAutoConfig {
      *
      * @param shardingJdbcProperties
      * @return
+     * @see SchemaMetaDataUtil.checkDataSourceTypeIncludeInstanceAndSetDatabaseTableMap
      */
     private ShardingRuleConfiguration createShardingRuleConfiguration(ShardingJdbcProperties shardingJdbcProperties) {
         ShardingRuleConfiguration result = new ShardingRuleConfiguration();
+        /*tables*/
+        result.getTables().add(getJoinOne());
+        result.getTables().add(getJoinTwo());
+        /*bindingTables 用于跨库*/
+//        result.getBindingTableGroups().add(new ShardingTableReferenceRuleConfiguration("join1", "t_student,kws_user"));
+        /*broadcastTables*/
+//        result.getBroadcastTables().add("t_student");
+//        result.getBroadcastTables().add("t_teacher");
 
-//        RuleConfiguration rules = shardingJdbcProperties.getRules();
-//        /*tables*/
-//        Map<String, ShardingTableRuleConfiguration> tables = rules.getTables();
-//        if (!CollectionUtils.isEmpty(tables)) {
-//            for (Map.Entry<String, ShardingTableRuleConfiguration> one : tables.entrySet()) {
-//                ShardingTableRuleConfiguration value = one.getValue();
-//                ShardingTableRuleConfiguration shardingTableRuleConfiguration = new ShardingTableRuleConfiguration(one.getKey(), value.getActualDataNodes());
-//                shardingTableRuleConfiguration.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("order_id", "snowflake"));
-//                shardingTableRuleConfiguration.setAuditStrategy(new ShardingAuditStrategyConfiguration(Collections.singleton("sharding_key_required_auditor"), true));
-//                result.getTables().add(shardingTableRuleConfiguration);
-//            }
-//        }
-
-        result.getTables().add(getOrderTableRuleConfiguration());
-//        result.getTables().add(getOrderItemTableRuleConfiguration());
-//        result.getBindingTableGroups().add(new ShardingTableReferenceRuleConfiguration("a",new ShardingTableRuleConfiguration("",new Object())));
-//        result.getBroadcastTables().add("t_address");
-//        result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("id", "t_student_inline"));
+        /*shardingAlgorithms*/
+//        Properties propsdb0 = new Properties();
+//        propsdb0.setProperty("algorithm-expression", "test_0");
+//        propsdb0.setProperty("allow-range-query-with-inline-sharding", "true");
+//        result.getShardingAlgorithms().put("default_db0_inline", new AlgorithmConfiguration("INLINE", propsdb0));
+//        Properties propsdb1 = new Properties();
+//        propsdb1.setProperty("algorithm-expression", "test_1");
+//        propsdb1.setProperty("allow-range-query-with-inline-sharding", "true");
+//        result.getShardingAlgorithms().put("default_db1_inline", new AlgorithmConfiguration("INLINE", propsdb1));
+//
+//        /*通过id进行分库*/
 //        Properties props = new Properties();
-//        props.setProperty("algorithm-expression", "t_student_{id % 2}");
-//        result.getShardingAlgorithms().put("t_student_inline", new AlgorithmConfiguration("INLINE", props));
+//        props.setProperty("algorithm-expression", "test_0");
+//        result.getShardingAlgorithms().put("default_database_id_inline", new AlgorithmConfiguration("INLINE", props));
+//        /*通过id进行分表*/
+//        Properties props1 = new Properties();
+//        props1.setProperty("algorithm-expression", "t_teacher_${id % 2}");
+//        result.getShardingAlgorithms().put("teacher_id_inline", new AlgorithmConfiguration("INLINE", props1));
+//        /*测试join跨库连表*/
+        Properties props2 = new Properties();
+        props2.setProperty("algorithm-expression", "test0");
+        result.getShardingAlgorithms().put("test0_inline", new AlgorithmConfiguration("INLINE", props2));
+        Properties props3 = new Properties();
+        props3.setProperty("algorithm-expression", "test1");
+        result.getShardingAlgorithms().put("test1_inline", new AlgorithmConfiguration("INLINE", props3));
+
+        //默认分库策略
+//        result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("id", "default_database_id_inline"));
+        //默认分表策略
+        result.setDefaultTableShardingStrategy(new NoneShardingStrategyConfiguration());
+        /*默认分片列*/
+//        result.setDefaultShardingColumn("id");
+        /*keyGenerators*/
         result.getKeyGenerators().put("snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties()));
-        result.getAuditors().put("sharding_key_required_auditor", new AlgorithmConfiguration("DML_SHARDING_CONDITIONS", new Properties()));
+        /*auditors*/
+//        result.getAuditors().put("sharding_key_required_auditor", new AlgorithmConfiguration("DML_SHARDING_CONDITIONS", new Properties()));
+        return result;
+    }
+
+    //join表
+    private ShardingTableRuleConfiguration getJoinOne() {
+        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_student", "test0.t_student");
+        result.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("", "test0_inline"));
+        result.setTableShardingStrategy(new NoneShardingStrategyConfiguration());
+//        result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "snowflake"));
+//        result.setAuditStrategy(new ShardingAuditStrategyConfiguration(Collections.singleton("sharding_key_required_auditor"), true));
+        return result;
+    }
+
+    //join表
+    private ShardingTableRuleConfiguration getJoinTwo() {
+        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("kws_user", "test1.kws_user");
+        result.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("", "test1_inline"));
+        result.setTableShardingStrategy(new NoneShardingStrategyConfiguration());
+//        result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "snowflake"));
+//        result.setAuditStrategy(new ShardingAuditStrategyConfiguration(Collections.singleton("sharding_key_required_auditor"), true));
         return result;
     }
 
+
+
+
+
+
+
+    //分库不分表
     private ShardingTableRuleConfiguration getOrderTableRuleConfiguration() {
-        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_student", "t_student_${[0, 1]}");
+        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_teacher", "test_${0..1}.t_teacher_${0..1}");
+        result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("id", "teacher_id_inline"));
         result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "snowflake"));
         result.setAuditStrategy(new ShardingAuditStrategyConfiguration(Collections.singleton("sharding_key_required_auditor"), true));
         return result;
     }
 
+    /**
+     * 分库不分表
+     *
+     * @return
+     */
+    private ShardingTableRuleConfiguration getOrderItemTableRuleConfiguration2() {
+        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_teacher", "test0.t_teacher");
+//        result.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("id", "default_database_id_inline"));
+//        result.setTableShardingStrategy(new NoneShardingStrategyConfiguration());
+        result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "snowflake"));
+        return result;
+    }
+
+    /**
+     * 分库不分表
+     *
+     * @return
+     */
     private ShardingTableRuleConfiguration getOrderItemTableRuleConfiguration() {
-        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_teacher", "test{0..1}.t_teacher_${[0, 1]}");
+        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_student", "test1.t_student");
+//        result.setDatabaseShardingStrategy(new StandardShardingStrategyConfiguration("id", "default_database_id_inline"));
+        result.setTableShardingStrategy(new NoneShardingStrategyConfiguration());
         result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "snowflake"));
         return result;
     }

+ 1 - 0
sckw-common/sckw-common-datasource/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm

@@ -0,0 +1 @@
+com.sckw.datasource.MyShardingAlgorithm

+ 3 - 5
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/TestController.java

@@ -42,10 +42,8 @@ public class TestController {
         return HttpResult.ok(testService.testSharding());
     }
 
-
-    @GetMapping("add")
-    public HttpResult add() {
-        testService.add();
-        return HttpResult.ok();
+    @GetMapping("testJoin")
+    public HttpResult testJoin(long id) {
+        return HttpResult.ok(testService.testJoin(id));
     }
 }

+ 3 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/TStudentMapper.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.system.model.TStudent;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * @Author xucaiqin
  * @date 2023-06-14 17:43:36
@@ -13,4 +15,5 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 @DS("sharding")
 public interface TStudentMapper extends BaseMapper<TStudent> {
+    List<TStudent> selectJoin();
 }

+ 3 - 2
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/TStudent.java

@@ -23,9 +23,10 @@ import java.time.LocalDateTime;
 @ToString
 @TableName(value = "t_student")
 public class TStudent {
-    @TableId(value = "id", type = IdType.AUTO)
+    @TableId(value = "id", type = IdType.INPUT)
     private Long id;
-
+    @TableField(value = "uid")
+    private Long uid;
     /**
      * 姓名
      */

+ 12 - 23
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/TestService.java

@@ -1,14 +1,13 @@
 package com.sckw.system.service;
 
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.system.dao.DbJoinDao;
 import com.sckw.system.dao.TStudentMapper;
 import com.sckw.system.model.TStudent;
 import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
-import java.time.LocalDateTime;
 import java.util.List;
 
 /**
@@ -16,6 +15,7 @@ import java.util.List;
  * @date 2023-06-09 09:15:50
  */
 @Service
+@Slf4j
 public class TestService {
     @Resource
     private DbJoinDao dbJoinDao;
@@ -34,26 +34,15 @@ public class TestService {
         return dbJoinDao.testSharding();
     }
 
-    public void add() {
-
-        TStudent tStudent = new TStudent();
-        tStudent.setName("");
-        tStudent.setSex("");
-        tStudent.setAge(0);
-        tStudent.setHeight(0.0D);
-        tStudent.setWeight(0.0D);
-        tStudent.setSno("");
-        tStudent.setGrade("");
-        tStudent.setClassLevel("asdf");
-        tStudent.setTime(LocalDateTime.now());
-        tStudent.setCreateTime(LocalDateTime.now());
-
-
-//        try {
-//            int insert = tStudentMapper.insert(tStudent);
-//        } catch (Exception e) {
-////            throw new RuntimeException(e);
-//        }
-        List<TStudent> tStudents = tStudentMapper.selectList(new LambdaQueryWrapper<>());
+
+    public Object testJoin(long id) {
+        try {
+            List<TStudent> tStudents = tStudentMapper.selectJoin();
+            System.out.println(tStudents);
+            return tStudents;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
     }
 }

+ 21 - 20
sckw-modules/sckw-system/src/main/resources/bootstrap-dev.yml

@@ -3,14 +3,14 @@ spring:
     nacos:
       discovery:
         # 服务注册地址
-        server-addr: 10.10.10.230:8848
+        server-addr: 127.0.0.1:8848
         # 命名空间
         namespace: sckw-service-platform-dev
         # 共享配置
         group: sckw-service-platform
       config:
         # 配置中心地址
-        server-addr: 10.10.10.230:8848
+        server-addr: 127.0.0.1:8848
         # 配置文件格式
         file-extension: yaml
         # 命名空间
@@ -36,10 +36,10 @@ spring:
             spring:
               rabbitmq:
                 virtual-host: /
-                host: 127.0.0.1
+                host: 10.10.10.230
                 port: 5672
-                username: admin
-                password: admin
+                username: sckw
+                password: Yy123...
   rabbitmq:
     username: admin
     password: admin
@@ -127,31 +127,32 @@ seata:
 
   sharding:
     enable: true
-    database-name: test
+    database-name: test0
     #    单机模式
-    #    mode:
-    #      type: Standalone
-    #      repository:
-    #        type: JDBC
-    #    集群模式,nacos持久化
     mode:
-      type: Cluster
+      type: Standalone
       repository:
-        type: Nacos
-        props:
-          server-lists: 127.0.0.1:8848
-          namespace: sckw-service-platform-dev
+#        type: Memory
+        type: JDBC
+    #    集群模式,nacos持久化
+    #    mode:
+    #      type: Cluster
+    #      repository:
+    #        type: Nacos
+    #        props:
+    #          server-lists: 127.0.0.1:8848
+    #          namespace: sckw-service-platform-dev
     dataSources:
       test0:
         driverClassName: com.mysql.cj.jdbc.Driver
-        jdbcUrl: jdbc:mysql://www.cometoyou.cn:3306/test
+        jdbcUrl: jdbc:mysql://www.cometoyou.cn:3306/test0
         username: root
         password: xcqXCQ@123456
       test1:
         driverClassName: com.mysql.cj.jdbc.Driver
-        jdbcUrl: jdbc:mysql://www.cometoyou.cn:3306/test2
-        username: root
-        password: xcqXCQ@123456
+        jdbcUrl: jdbc:mysql://10.10.10.230:3306/sckw_system
+        username: sckw_dev
+        password: Yy123...
     props:
       sql-show: true
     rules:

+ 42 - 19
sckw-modules/sckw-system/src/main/resources/mapper/TStudentMapper.xml

@@ -1,23 +1,46 @@
 <?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.sckw.system.dao.TStudentMapper">
-  <resultMap id="BaseResultMap" type="com.sckw.system.model.TStudent">
-    <!--@mbg.generated-->
-    <!--@Table t_student-->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="name" jdbcType="VARCHAR" property="name" />
-    <result column="sex" jdbcType="CHAR" property="sex" />
-    <result column="age" jdbcType="INTEGER" property="age" />
-    <result column="height" jdbcType="DOUBLE" property="height" />
-    <result column="weight" jdbcType="DOUBLE" property="weight" />
-    <result column="sno" jdbcType="VARCHAR" property="sno" />
-    <result column="grade" jdbcType="VARCHAR" property="grade" />
-    <result column="class" jdbcType="VARCHAR" property="class" />
-    <result column="time" jdbcType="TIMESTAMP" property="time" />
-    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id, `name`, sex, age, height, weight, sno, grade, `class`, `time`, create_time
-  </sql>
+    <resultMap id="BaseResultMap" type="com.sckw.system.model.TStudent">
+        <!--@mbg.generated-->
+        <!--@Table t_student-->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <id column="uid" jdbcType="BIGINT" property="uid"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="sex" jdbcType="CHAR" property="sex"/>
+        <result column="age" jdbcType="INTEGER" property="age"/>
+        <result column="height" jdbcType="DOUBLE" property="height"/>
+        <result column="weight" jdbcType="DOUBLE" property="weight"/>
+        <result column="sno" jdbcType="VARCHAR" property="sno"/>
+        <result column="grade" jdbcType="VARCHAR" property="grade"/>
+        <result column="class_level" jdbcType="VARCHAR" property="classLevel"/>
+        <result column="time" jdbcType="TIMESTAMP" property="time"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+    </resultMap>
+    <sql id="Base_Column_List">
+        <!--@mbg.generated-->
+        id,
+        `name`,
+        sex,
+        age,
+        height,
+        weight,
+        sno,
+        grade,
+        `class_level`,
+        `time`,
+        create_time
+    </sql>
+    <!--Can not support multiple different database.-->
+    <!--   <select id="selectJoin" resultMap="BaseResultMap">
+           select *
+           from test0.t_student ts
+                    INNER join test1.t_teacher tt on ts.id = tt.id
+           where ts.id > 0
+       </select> -->
+    <select id="selectJoin" resultMap="BaseResultMap">
+        select *
+        from t_student ts
+                 INNER join kws_user ku on ts.uid = ku.id
+    </select>
 </mapper>