Explorar el Código

test类清理

miemie hace 3 años
padre
commit
aeda48e61e
Se han modificado 24 ficheros con 0 adiciones y 1407 borrados
  1. 0 1
      build.gradle
  2. 0 35
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/MyBaseMapper.java
  3. 0 59
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/MysqlMetaObjectHandler.java
  4. 0 160
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/MysqlTestDataMapperTest.java
  5. 0 147
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/SelectCountDistinctTest.java
  6. 0 71
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/config/DBConfig.java
  7. 0 105
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/config/MybatisPlusConfig.java
  8. 0 67
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/CommonData.java
  9. 0 54
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/CommonLogicData.java
  10. 0 39
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/FillTenantEnumVersion.java
  11. 0 40
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/MysqlData.java
  12. 0 52
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/ResultMapEntity.java
  13. 0 42
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/enums/TestEnum.java
  14. 0 43
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/mapper/MysqlDataMapper.java
  15. 0 31
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/mapper/commons/CommonDataCopyMapper.java
  16. 0 46
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/mapper/commons/CommonDataMapper.java
  17. 0 35
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/mapper/commons/CommonLogicDataMapper.java
  18. 0 41
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/mapper/commons/ResultMapEntityMapper.java
  19. 0 72
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/type/JsonTypeHandler.java
  20. 0 90
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/type/ListTypeHandler.java
  21. 0 86
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/type/MapTypeHandler.java
  22. 0 19
      mybatis-plus/src/test/resources/mapper/ResultMapEntityMapper.xml
  23. 0 9
      mybatis-plus/src/test/resources/mysql/spring-test-mysql.xml
  24. 0 63
      mybatis-plus/src/test/resources/mysql/test_data.ddl.sql

+ 0 - 1
build.gradle

@@ -169,7 +169,6 @@ subprojects {
     test {
         dependsOn("cleanTest", "generatePomFileForMavenJavaPublication")
         useJUnitPlatform()
-        exclude("**/mysql/**")
         exclude("**/phoenix/**")
     }
 

+ 0 - 35
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/MyBaseMapper.java

@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.toolkit.Constants;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * @author miemie
- * @since 2018-09-13
- */
-public interface MyBaseMapper<T> extends BaseMapper<T> {
-
-    int deleteByIdWithFill(T entity);
-
-    int insertBatchSomeColumn(List<T> entityList);
-
-    int alwaysUpdateSomeColumnById(@Param(Constants.ENTITY) T entity);
-}

+ 0 - 59
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/MysqlMetaObjectHandler.java

@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql;
-
-import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
-import org.apache.ibatis.reflection.MetaObject;
-
-import java.time.LocalDateTime;
-
-/**
- * 测试,自定义元对象字段填充控制器,实现公共字段自动写入
- *
- * @author hubin
- * @since 2017-06-25
- */
-public class MysqlMetaObjectHandler implements MetaObjectHandler {
-
-    /**
-     * 测试 user 表 name 字段为空自动填充
-     */
-    @Override
-    public void insertFill(MetaObject metaObject) {
-        System.out.println("*************************");
-        System.out.println("insert of mysql fill");
-        System.out.println("*************************");
-        // 测试下划线
-        Object createDatetime = this.getFieldValByName("createDatetime", metaObject);
-        System.out.println("createDatetime=" + createDatetime);
-        if (createDatetime == null) {
-            //测试实体没有的字段,配置在公共填充,不应该set到实体里面
-            this.strictInsertFill(metaObject, "createDatetime1", LocalDateTime.class, LocalDateTime.now())
-                .strictInsertFill(metaObject, "createDatetime", LocalDateTime.class, LocalDateTime.now());
-        }
-    }
-
-    @Override
-    public void updateFill(MetaObject metaObject) {
-        System.out.println("*************************");
-        System.out.println("update of mysql fill");
-        System.out.println("*************************");
-        //测试实体没有的字段,配置在公共填充,不应该set到实体里面
-        this.strictUpdateFill(metaObject, "updateDatetime1", LocalDateTime.class, LocalDateTime.now())
-            .strictUpdateFill(metaObject, "updateDatetime", LocalDateTime.class, LocalDateTime.now());
-    }
-}
-

+ 0 - 160
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/MysqlTestDataMapperTest.java

@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql;
-
-import com.baomidou.mybatisplus.core.MybatisConfiguration;
-import com.baomidou.mybatisplus.test.mysql.entity.CommonData;
-import com.baomidou.mybatisplus.test.mysql.entity.CommonLogicData;
-import com.baomidou.mybatisplus.test.mysql.entity.MysqlData;
-import com.baomidou.mybatisplus.test.mysql.entity.ResultMapEntity;
-import com.baomidou.mybatisplus.test.mysql.enums.TestEnum;
-import com.baomidou.mybatisplus.test.mysql.mapper.MysqlDataMapper;
-import com.baomidou.mybatisplus.test.mysql.mapper.commons.CommonDataMapper;
-import com.baomidou.mybatisplus.test.mysql.mapper.commons.CommonLogicDataMapper;
-import com.baomidou.mybatisplus.test.mysql.mapper.commons.ResultMapEntityMapper;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.session.Configuration;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.MethodOrderer;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestMethodOrder;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import javax.annotation.Resource;
-import java.util.*;
-
-import static java.util.function.Function.identity;
-import static java.util.stream.Collectors.toMap;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-/**
- * Mybatis Plus mysql Junit Test
- *
- * @author hubin
- * @since 2018-06-05
- */
-@DirtiesContext
-@TestMethodOrder(MethodOrderer.Alphanumeric.class)
-@ExtendWith(SpringExtension.class)
-@ContextConfiguration(locations = {"classpath:mysql/spring-test-mysql.xml"})
-class MysqlTestDataMapperTest {
-
-    protected final List<String> list = Arrays.asList("1", "2", "3");
-    protected final Map<String, Object> map = list.parallelStream().collect(toMap(identity(), identity()));
-    private static final int success = 1;
-    private static final int fail = 0;
-    @Resource(name = "commonDataMapper")
-    protected CommonDataMapper commonDataMapper;
-    @Resource(name = "commonLogicDataMapper")
-    protected CommonLogicDataMapper commonLogicDataMapper;
-    @Resource
-    protected ResultMapEntityMapper resultMapEntityMapper;
-    @Autowired
-    private SqlSessionFactory sqlSessionFactory;
-
-    @Resource
-    private MysqlDataMapper mysqlMapper;
-
-    @Test
-    void a00() {
-        Configuration configuration = sqlSessionFactory.getConfiguration();
-        assertThat(configuration).isInstanceOf(MybatisConfiguration.class);
-        MappedStatement mappedStatement = configuration.getMappedStatement("com.baomidou.mybatisplus.test.mysql.mapper.MysqlDataMapper.getRandomOne");
-        assertThat(mappedStatement).isNotNull();
-    }
-
-    @Test
-    void a01_insertForeach() {
-        for (int i = 1; i < 20; i++) {
-            Long id = (long) i;
-            String str = String.format("第%s条数据", i);
-            commonDataMapper.insert(new CommonData().setTestInt(i).setTestStr(str).setId(id)
-                .setTestEnum(TestEnum.ONE));
-            commonLogicDataMapper.insert(new CommonLogicData().setTestInt(i).setTestStr(str).setId(id));
-            resultMapEntityMapper.insert(new ResultMapEntity().setId(id).setList(list).setMap(map).setMapp(map));
-            MysqlData data = new MysqlData().setOrder(i).setGroup(i).setTestStr(str).setYaHoStr(str);
-            mysqlMapper.insert(data);
-            assertThat(data.getId()).isNotNull();
-        }
-    }
-
-    @Test
-    void a011_insertIdAuto() {
-        commonDataMapper.delete(null);
-        for (int i = 0; i < 20; i++) {
-            String str = String.format("第%s条数据", i);
-            commonDataMapper.insert(new CommonData().setTestInt(i).setTestStr(str)
-                    .setId(Long.valueOf(i))
-                .setTestEnum(TestEnum.ONE));
-        }
-        Assertions.assertEquals(20, commonDataMapper.selectCount(null));
-        commonDataMapper.delete(null);
-    }
-
-    @Test
-    void a02_insertBatch() {
-        int size = 9;
-        List<CommonData> commonDataList = new ArrayList<>();
-        List<CommonLogicData> commonLogicDataList = new ArrayList<>();
-        List<MysqlData> mysqlDataList = new ArrayList<>();
-        for (int i = 0; i < size; i++) {
-            String str = i + "条";
-            commonDataList.add(new CommonData().setTestInt(i).setTestEnum(TestEnum.TWO).setTestStr(str));
-            commonLogicDataList.add(new CommonLogicData().setTestInt(i).setTestStr(str));
-            mysqlDataList.add(new MysqlData().setOrder(i).setGroup(i).setTestStr(str).setYaHoStr(str));
-        }
-        assertEquals(size, commonDataMapper.insertBatchSomeColumn(commonDataList));
-        assertEquals(size, commonLogicDataMapper.insertBatchSomeColumn(commonLogicDataList));
-        assertEquals(size, mysqlMapper.insertBatchSomeColumn(mysqlDataList));
-    }
-
-    @Test
-    void a03_deleteById() {
-        long id = 1L;
-        assertEquals(success, commonDataMapper.deleteById(id));
-        assertEquals(success, commonLogicDataMapper.deleteById(id));
-        assertEquals(success, mysqlMapper.deleteById(id));
-    }
-
-    @Test
-    void a04_deleteByMap() {
-        long id = 2L;
-        Map<String, Object> map = new HashMap<>();
-        map.put("id", id);
-        map.put("test_int", 5);
-        assertEquals(fail, commonDataMapper.deleteByMap(map));
-        assertEquals(fail, commonLogicDataMapper.deleteByMap(map));
-        Map<String, Object> map2 = new HashMap<>();
-        map2.put("id", id);
-        map2.put("`order`", 5);
-        assertEquals(fail, mysqlMapper.deleteByMap(map2));
-    }
-
-    @Test
-    void a05_select() {
-        long id = 4L;
-        List<ResultMapEntity> entitys = resultMapEntityMapper.selectBatchIds(Collections.singletonList(id));
-        assertThat(entitys).isNotEmpty();
-        assertThat(entitys.size()).isEqualTo(1);
-        assertThat(entitys.get(0).getColumn4()).isNotNull();
-    }
-}

+ 0 - 147
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/SelectCountDistinctTest.java

@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 2011-2019, hubin (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.test.mysql.entity.CommonData;
-import com.baomidou.mybatisplus.test.mysql.entity.CommonLogicData;
-import com.baomidou.mybatisplus.test.mysql.mapper.commons.CommonDataMapper;
-import com.baomidou.mybatisplus.test.mysql.mapper.commons.CommonLogicDataMapper;
-import org.junit.jupiter.api.*;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-@DirtiesContext
-@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-@ExtendWith(SpringExtension.class)
-@ContextConfiguration(locations = {"classpath:mysql/spring-test-mysql.xml"})
-class SelectCountDistinctTest {
-
-    @Resource
-    private CommonLogicDataMapper commonLogicMapper;
-    @Resource
-    private CommonDataMapper commonDataMapper;
-
-    @Test
-    @Order(1)
-    void testCountDistinct() {
-        QueryWrapper<CommonData> distinct = new QueryWrapper<>();
-        distinct.select("distinct test_int");
-        distinct.eq("test_int", 25)
-                .or()
-                .eq("test_str", "test")
-                .first("/*Force Master*/");
-        long count = commonDataMapper.selectCount(distinct);
-        Assertions.assertEquals(1, count);
-    }
-
-    @Test
-    @Order(2)
-    void testCountDistinctTwoColumn() {
-        QueryWrapper<CommonData> distinct = new QueryWrapper<>();
-        distinct.select("distinct test_int, test_str");
-        distinct.eq("test_int", 25).or().eq("test_str", "test");
-        long count = commonDataMapper.selectCount(distinct);
-        Assertions.assertEquals(1, count);
-    }
-
-    @Test
-    @Order(3)
-    void testLogicCountDistinct() {
-        QueryWrapper<CommonLogicData> distinct = new QueryWrapper<>();
-        distinct.select("distinct test_int");
-        distinct.eq("test_int", 25).or().eq("test_str", "test");
-        long count = commonLogicMapper.selectCount(distinct);
-        Assertions.assertEquals(1, count);
-    }
-
-    @Test
-    @Order(4)
-    void testLogicSelectList() {
-        QueryWrapper<CommonLogicData> commonQuery = new QueryWrapper<>();
-        List<CommonLogicData> commonLogicDataList = commonLogicMapper.selectList(commonQuery);
-        CommonLogicData commonLogicData = commonLogicDataList.get(0);
-        Assertions.assertEquals(25, commonLogicData.getTestInt().intValue());
-        Assertions.assertEquals("test", commonLogicData.getTestStr());
-    }
-
-    @Test
-    @Order(5)
-    void testLogicCountDistinctUseLambda() {
-        LambdaQueryWrapper<CommonLogicData> lambdaQueryWrapper =
-            new QueryWrapper<CommonLogicData>().select("distinct test_int").lambda();
-        long count = commonLogicMapper.selectCount(lambdaQueryWrapper);
-        Assertions.assertEquals(1, count);
-    }
-
-    @Test
-    @Order(6)
-    void testCountDistinctUseLambda() {
-        LambdaQueryWrapper<CommonData> lambdaQueryWrapper =
-            new QueryWrapper<CommonData>().select("distinct test_int, test_str").lambda();
-        long count = commonDataMapper.selectCount(lambdaQueryWrapper);
-        Assertions.assertEquals(1, count);
-    }
-
-    @Test
-    @Order(7)
-    void testLogicSelectCountWithoutDistinct() {
-        QueryWrapper<CommonLogicData> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("test_int", 25).or().eq("test_str", "test");
-        long count = commonLogicMapper.selectCount(queryWrapper);
-        Assertions.assertEquals(2, count);
-    }
-
-    @Test
-    @Order(8)
-    void testCountDistinctWithoutDistinct() {
-        QueryWrapper<CommonData> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("test_int", 25).or().eq("test_str", "test");
-        long count = commonDataMapper.selectCount(queryWrapper);
-        Assertions.assertEquals(2, count);
-    }
-
-    @Test
-    @Order(9)
-    void testSelectPageWithoutDistinct() {
-        QueryWrapper<CommonData> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("test_int", 25).or().eq("test_str", "test");
-        IPage<CommonData> page = commonDataMapper.selectPage(new Page<>(1, 10), queryWrapper);
-        Assertions.assertEquals(2, page.getTotal());
-        Assertions.assertNotNull(page.getRecords().get(0));
-        Assertions.assertNotNull(page.getRecords().get(1));
-    }
-
-    @Test
-    @Order(10)
-    void testSelectPageWithDistinct() {
-        QueryWrapper<CommonData> queryWrapper = new QueryWrapper<>();
-        queryWrapper.select("distinct test_int, test_str");
-        queryWrapper.eq("test_int", 25).or().eq("test_str", "test");
-        IPage<CommonData> page = commonDataMapper.selectPage(new Page<>(1, 10), queryWrapper);
-        Assertions.assertEquals(1, page.getTotal());
-        Assertions.assertNotNull(page.getRecords().get(0));
-    }
-
-}

+ 0 - 71
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/config/DBConfig.java

@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-import org.springframework.jdbc.datasource.SimpleDriverDataSource;
-import org.springframework.jdbc.datasource.init.DataSourceInitializer;
-import org.springframework.jdbc.datasource.init.DatabasePopulator;
-import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-import javax.sql.DataSource;
-import java.io.IOException;
-
-/**
- * @author miemie
- * @since 2018/6/7
- */
-@Configuration
-@EnableTransactionManagement
-public class DBConfig {
-
-    @Bean("dataSource")
-    public DataSource dataSource() {
-        SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
-        dataSource.setDriverClass(com.mysql.cj.jdbc.Driver.class);
-        dataSource.setUrl("jdbc:mysql://localhost:3306/mybatis_plus?useSSL=false&useUnicode=true&characterEncoding=UTF-8");
-        dataSource.setUsername("root");
-        dataSource.setPassword("");
-        return dataSource;
-    }
-
-    @Bean
-    public DataSourceTransactionManager transactionManager(DataSource ds) {
-        return new DataSourceTransactionManager(ds);
-    }
-
-    @Bean
-    public DataSourceInitializer dataSourceInitializer(DataSource dataSource) throws IOException {
-        final DataSourceInitializer initializer = new DataSourceInitializer();
-        initializer.setDataSource(dataSource);
-        initializer.setDatabasePopulator(databasePopulator());
-        initializer.setEnabled(true);
-        return initializer;
-    }
-
-    private DatabasePopulator databasePopulator() throws IOException {
-        ResourceDatabasePopulator resourceDatabasePopulator = new ResourceDatabasePopulator();
-        resourceDatabasePopulator.setContinueOnError(false);
-        resourceDatabasePopulator.addScripts(
-            new PathMatchingResourcePatternResolver().getResources("classpath:/mysql/*.sql")
-        );
-        return resourceDatabasePopulator;
-    }
-}

+ 0 - 105
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/config/MybatisPlusConfig.java

@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.config;
-
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.core.MybatisConfiguration;
-import com.baomidou.mybatisplus.core.config.GlobalConfig;
-import com.baomidou.mybatisplus.core.injector.AbstractMethod;
-import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
-import com.baomidou.mybatisplus.core.metadata.TableInfo;
-import com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory;
-import com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById;
-import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;
-import com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill;
-import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
-import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
-import com.baomidou.mybatisplus.test.mysql.MysqlMetaObjectHandler;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.apache.ibatis.type.JdbcType;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-
-import javax.sql.DataSource;
-import java.util.List;
-
-/**
- * Mybatis Plus Config
- *
- * @author Caratacus
- * @since 2017/4/1
- */
-@Configuration
-@MapperScan("com.baomidou.mybatisplus.test.mysql.mapper")
-public class MybatisPlusConfig {
-
-    @Bean("mybatisSqlSession")
-    public SqlSessionFactory sqlSessionFactory(DataSource dataSource, GlobalConfig globalConfig) throws Exception {
-        MybatisSqlSessionFactoryBean sqlSessionFactory = new MybatisSqlSessionFactoryBean();
-        /* 数据源 */
-        sqlSessionFactory.setDataSource(dataSource);
-        /* 枚举扫描 */
-        sqlSessionFactory.setTypeEnumsPackage("com.baomidou.mybatisplus.test.mysql.enums");
-        /* xml扫描 */
-        sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
-            .getResources("classpath:/mapper/*.xml"));
-        /* 扫描 typeHandler */
-//        sqlSessionFactory.setTypeHandlersPackage("com.baomidou.mybatisplus.test.base.type");
-        MybatisConfiguration configuration = new MybatisConfiguration();
-        configuration.setJdbcTypeForNull(JdbcType.NULL);
-        /* 驼峰转下划线 */
-        configuration.setMapUnderscoreToCamelCase(true);
-        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
-        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
-        mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
-        sqlSessionFactory.setPlugins(mybatisPlusInterceptor);
-        /* map 下划线转驼峰 */
-        configuration.setObjectWrapperFactory(new MybatisMapWrapperFactory());
-        sqlSessionFactory.setConfiguration(configuration);
-        /* 自动填充插件 */
-        globalConfig.setMetaObjectHandler(new MysqlMetaObjectHandler());
-        sqlSessionFactory.setGlobalConfig(globalConfig);
-        return sqlSessionFactory.getObject();
-    }
-
-    @Bean
-    public GlobalConfig globalConfig() {
-        GlobalConfig conf = new GlobalConfig();
-        conf.setDbConfig(new GlobalConfig.DbConfig()
-            .setColumnFormat("`%s`"));
-        DefaultSqlInjector logicSqlInjector = new DefaultSqlInjector() {
-            /**
-             * 注入自定义全局方法
-             */
-            @Override
-            public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
-                List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
-                methodList.add(new LogicDeleteByIdWithFill());
-                // 不要逻辑删除字段, 不要乐观锁字段, 不要填充策略是 UPDATE 的字段
-                methodList.add(new InsertBatchSomeColumn(t -> !t.isLogicDelete() && !t.isVersion() && t.getFieldFill() != FieldFill.UPDATE));
-                // 不要填充策略是 INSERT 的字段, 不要字段名是 column4 的字段
-                methodList.add(new AlwaysUpdateSomeColumnById(t -> t.getFieldFill() != FieldFill.INSERT && !t.getProperty().equals("column4")));
-                return methodList;
-            }
-        };
-        conf.setSqlInjector(logicSqlInjector);
-        return conf;
-    }
-}

+ 0 - 67
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/CommonData.java

@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.entity;
-
-import com.baomidou.mybatisplus.annotation.*;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import com.baomidou.mybatisplus.test.mysql.enums.TestEnum;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-import org.apache.ibatis.type.JdbcType;
-
-import java.time.LocalDateTime;
-
-/**
- * 包含功能:
- * 1.自动填充        验证无误
- * 2.乐观锁          验证无误
- * 3.多租户          验证无误
- * 4.枚举            验证无误
- *
- * @author meimie
- * @since 2018/6/7
- */
-@Data
-@Accessors(chain = true)
-@EqualsAndHashCode(callSuper = true)
-public class CommonData extends Model<CommonData> {
-
-    /**
-     * serialVersionUID
-     */
-    private static final long serialVersionUID = 5651603508613034190L;
-    @TableId(type = IdType.AUTO)
-    private Long id;
-    @TableField(jdbcType = JdbcType.INTEGER)
-    private Integer testInt;
-    @TableField
-    private String testStr;
-    @TableField(value = "c_time", fill = FieldFill.INSERT)
-    private LocalDateTime createDatetime;
-    @TableField(value = "u_time", fill = FieldFill.UPDATE)
-    private LocalDateTime updateDatetime;
-    private TestEnum testEnum;
-
-    @Version
-    private Integer version;
-//    /**
-//     * 多租户
-//     * 不用配置实体字段,但是数据库需要该字段
-//     */
-//    private Long tenantId;
-
-}

+ 0 - 54
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/CommonLogicData.java

@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.entity;
-
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableLogic;
-import com.baomidou.mybatisplus.annotation.Version;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import java.time.LocalDateTime;
-
-/**
- * 包含功能:
- * 1.自动填充        验证无误
- * 2.逻辑删除        验证无误
- * 3.乐观锁          验证无误
- * 4.不搜索指定字段   验证无误
- *
- * @author meimie
- * @since 2018/6/7
- */
-@Data
-@Accessors(chain = true)
-public class CommonLogicData {
-
-    private Long id;
-    private Integer testInt;
-    private String testStr;
-    @TableField(value = "c_time", fill = FieldFill.INSERT)
-    private LocalDateTime createDatetime;
-    @TableField(value = "u_time", fill = FieldFill.UPDATE)
-    private LocalDateTime updateDatetime;
-    @TableLogic
-    @TableField(select = false)
-    private Integer deleted;
-
-    @Version
-    private Integer version;
-}

+ 0 - 39
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/FillTenantEnumVersion.java

@@ -1,39 +0,0 @@
-package com.baomidou.mybatisplus.test.mysql.entity;
-
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.Version;
-import com.baomidou.mybatisplus.test.mysql.enums.TestEnum;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import java.time.LocalDateTime;
-
-/**
- * @author miemie
- * @since 2019-11-22
- */
-@Data
-@Accessors(chain = true)
-@TableName("ftev")
-public class FillTenantEnumVersion {
-
-    private Long id;
-    private Integer tInt;
-    @TableField //无意义
-    private String tStr;
-    @TableField(value = "c_time", fill = FieldFill.INSERT)
-    private LocalDateTime createTime;
-    @TableField(value = "u_time", fill = FieldFill.UPDATE)
-    private LocalDateTime updTime;
-    private TestEnum testEnum;
-
-    @Version
-    private Integer version;
-//    /**
-//     * 多租户
-//     * 不用配置实体字段,但是数据库需要该字段
-//     */
-//    private Long tenantId;
-}

+ 0 - 40
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/MysqlData.java

@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.entity;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-/**
- * @author miemie
- * @since 2018-08-18
- */
-@Data
-@Accessors(chain = true)
-public class MysqlData {
-
-    @TableId(type = IdType.AUTO)
-    private Long id;
-    private Integer order;
-    private Integer group;
-    @TableField(value = "test_str")
-    private String testStr;
-    @TableField(value = "lambda_str", keepGlobalFormat = true)
-    private String yaHoStr;
-}

+ 0 - 52
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/entity/ResultMapEntity.java

@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.entity;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.test.mysql.type.JsonTypeHandler;
-import com.baomidou.mybatisplus.test.mysql.type.ListTypeHandler;
-import com.baomidou.mybatisplus.test.mysql.type.MapTypeHandler;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author miemie
- * @since 2019-01-19
- */
-@Data
-@Accessors(chain = true)
-//@TableName(resultMap = "resultChildren1")
-@TableName(autoResultMap = true)
-public class ResultMapEntity {
-
-    private Long id;
-
-    private String column1;
-    private String column2;
-    private String column3;
-    @TableField("column_1234")
-    private String column4;
-    @TableField(typeHandler = ListTypeHandler.class)
-    private List<String> list;
-    @TableField(typeHandler = MapTypeHandler.class)
-    private Map<String, Object> map;
-    @TableField(typeHandler = JsonTypeHandler.class)
-    private Map<String, Object> mapp;
-}

+ 0 - 42
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/enums/TestEnum.java

@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.enums;
-
-import com.baomidou.mybatisplus.annotation.IEnum;
-import lombok.Getter;
-
-/**
- * @author miemie
- * @since 2018-08-19
- */
-@Getter
-public enum TestEnum implements IEnum<Integer> {
-    ONE(1, "一"),
-    TWO(2, "二");
-
-    private final int code;
-    private final String val;
-
-    TestEnum(int code, String val) {
-        this.code = code;
-        this.val = val;
-    }
-
-    @Override
-    public Integer getValue() {
-        return code;
-    }
-}

+ 0 - 43
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/mapper/MysqlDataMapper.java

@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.mapper;
-
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.toolkit.Constants;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.test.mysql.MyBaseMapper;
-import com.baomidou.mybatisplus.test.mysql.entity.MysqlData;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author miemie
- * @since 2018-08-18
- */
-public interface MysqlDataMapper extends MyBaseMapper<MysqlData> {
-
-    @Select("select * from mysql_data ${ew.customSqlSegment}")
-    List<MysqlData> getAll(@Param(Constants.WRAPPER) Wrapper<?> wrapper);
-
-    @Select("select * from mysql_data")
-    Page<Map<String, Object>> getMaps(Page page);
-
-    @Select("select * from mysql_data limit 1")
-    Map<String, Object> getRandomOne(String xx, String ww);
-}

+ 0 - 31
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/mapper/commons/CommonDataCopyMapper.java

@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.mapper.commons;
-
-import com.baomidou.mybatisplus.test.mysql.entity.CommonData;
-import org.apache.ibatis.annotations.Select;
-
-import java.util.Optional;
-
-/**
- * @author miemie
- * @since 2019-04-11
- */
-public interface CommonDataCopyMapper {
-
-    @Select("select * from common_data where id = #{id}")
-    Optional<CommonData> selectById(Long id);
-}

+ 0 - 46
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/mapper/commons/CommonDataMapper.java

@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.mapper.commons;
-
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.toolkit.Constants;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.test.mysql.MyBaseMapper;
-import com.baomidou.mybatisplus.test.mysql.entity.CommonData;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * @author miemie
- * @since 2018/6/7
- */
-public interface CommonDataMapper extends MyBaseMapper<CommonData> {
-
-    @Select("select * from common_data")
-    List<CommonData> getAllNoTenant();
-
-    @Select("select * from common_data ${ew.customSqlSegment}")
-    List<CommonData> getByWrapper(@Param(Constants.WRAPPER) Wrapper wrapper);
-
-    @Select("select * from common_data where id = #{ooxx}")
-    Optional<CommonData> getById(Long id);
-
-    @Select("select * from common_data")
-    Page<CommonData> myPage(Page<CommonData> page);
-}

+ 0 - 35
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/mapper/commons/CommonLogicDataMapper.java

@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.mapper.commons;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Constants;
-import com.baomidou.mybatisplus.test.mysql.MyBaseMapper;
-import com.baomidou.mybatisplus.test.mysql.entity.CommonLogicData;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-
-import java.util.List;
-
-/**
- * @author miemie
- * @since 2018-07-06
- */
-public interface CommonLogicDataMapper extends MyBaseMapper<CommonLogicData> {
-
-    @Select("select * from common_logic_data ${ew.customSqlSegment}")
-    List<CommonLogicData> getByWrapper(@Param(Constants.WRAPPER) LambdaQueryWrapper wrapper);
-}

+ 0 - 41
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/mapper/commons/ResultMapEntityMapper.java

@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.mapper.commons;
-
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.toolkit.Constants;
-import com.baomidou.mybatisplus.test.mysql.MyBaseMapper;
-import com.baomidou.mybatisplus.test.mysql.entity.ResultMapEntity;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.ResultMap;
-import org.apache.ibatis.annotations.Select;
-
-import java.io.Serializable;
-
-/**
- * @author miemie
- * @since 2019-01-19
- */
-public interface ResultMapEntityMapper extends MyBaseMapper<ResultMapEntity> {
-
-    @Override
-    @ResultMap("resultChildren1")
-    @Select("select * from result_map_entity where id = #{id}")
-    ResultMapEntity selectById(Serializable id);
-
-    @Override
-    ResultMapEntity selectOne(@Param(Constants.WRAPPER) Wrapper<ResultMapEntity> queryWrapper);
-}

+ 0 - 72
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/type/JsonTypeHandler.java

@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.type;
-
-import com.alibaba.fastjson.JSON;
-import org.apache.ibatis.type.BaseTypeHandler;
-import org.apache.ibatis.type.JdbcType;
-
-import java.sql.CallableStatement;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * 添加mybatis json类型装换支持
- * https://github.com/mybatis/mybatis-3/pull/1003
- */
-public class JsonTypeHandler<T> extends BaseTypeHandler<T> {
-
-    private Class<T> type;
-
-    public JsonTypeHandler(Class<T> type) {
-        if (type == null) {
-            throw new IllegalArgumentException("Type argument cannot be null");
-        }
-        System.out.println("我被构造了,类型" + type);
-        this.type = type;
-    }
-
-    @Override
-    public void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {
-        ps.setString(i, JSON.toJSONString(parameter));
-    }
-
-    @Override
-    public T getNullableResult(ResultSet rs, String columnName) throws SQLException {
-        String value = rs.getString(columnName);
-        if (value != null)
-            return JSON.parseObject(value, type);
-        return null;
-    }
-
-    @Override
-    public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
-        String value = rs.getString(columnIndex);
-        if (value != null)
-            return JSON.parseObject(value, type);
-        return null;
-    }
-
-    @Override
-    public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
-        String value = cs.getString(columnIndex);
-        if (value != null)
-            return JSON.parseObject(value, type);
-        return null;
-    }
-
-}

+ 0 - 90
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/type/ListTypeHandler.java

@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.type;
-
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.ibatis.type.BaseTypeHandler;
-import org.apache.ibatis.type.JdbcType;
-
-import java.io.IOException;
-import java.sql.CallableStatement;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-
-/**
- * @author miemie
- * @since 2019-01-22
- */
-public class ListTypeHandler extends BaseTypeHandler<List<?>> {
-
-    private final ObjectMapper objectMapper = new ObjectMapper();
-
-    @Override
-    public void setNonNullParameter(PreparedStatement ps, int i, List<?> parameter, JdbcType jdbcType) throws SQLException {
-        try {
-            ps.setString(i, objectMapper.writeValueAsString(parameter));
-        } catch (JsonProcessingException e) {
-            ps.setString(i, null);
-        }
-    }
-
-    @Override
-    public List<?> getNullableResult(ResultSet rs, String columnName) throws SQLException {
-        String result = rs.getString(columnName);
-        if (StringUtils.isNotBlank(result)) {
-            try {
-                return objectMapper.readValue(result, new TypeReference<List<String>>() {
-                });
-            } catch (IOException e) {
-                return null;
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public List<?> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
-        String result = rs.getString(columnIndex);
-        if (StringUtils.isNotBlank(result)) {
-            try {
-                return objectMapper.readValue(result, new TypeReference<List<String>>() {
-                });
-            } catch (IOException e) {
-                return null;
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public List<?> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
-        String result = cs.getString(columnIndex);
-        if (StringUtils.isNotBlank(result)) {
-            try {
-                return objectMapper.readValue(result, new TypeReference<List<String>>() {
-                });
-            } catch (IOException e) {
-                return null;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 86
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/type/MapTypeHandler.java

@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * <p>
- * https://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.baomidou.mybatisplus.test.mysql.type;
-
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.ibatis.type.BaseTypeHandler;
-import org.apache.ibatis.type.JdbcType;
-
-import java.io.IOException;
-import java.sql.CallableStatement;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Map;
-
-/**
- * @author miemie
- * @since 2019-01-22
- */
-public class MapTypeHandler extends BaseTypeHandler<Map<?, ?>> {
-
-    private final ObjectMapper objectMapper = new ObjectMapper();
-
-    @Override
-    public void setNonNullParameter(PreparedStatement ps, int i, Map<?, ?> parameter, JdbcType jdbcType) throws SQLException {
-        try {
-            ps.setString(i, objectMapper.writeValueAsString(parameter));
-        } catch (JsonProcessingException e) {
-            ps.setString(i, null);
-        }
-    }
-
-    @Override
-    public Map<?, ?> getNullableResult(ResultSet rs, String columnName) throws SQLException {
-        String result = rs.getString(columnName);
-        if (StringUtils.isNotBlank(result)) {
-            try {
-                return objectMapper.readValue(result, Map.class);
-            } catch (IOException e) {
-                return null;
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public Map<?, ?> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
-        String result = rs.getString(columnIndex);
-        if (StringUtils.isNotBlank(result)) {
-            try {
-                return objectMapper.readValue(result, Map.class);
-            } catch (IOException e) {
-                return null;
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public Map<?, ?> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
-        String result = cs.getString(columnIndex);
-        if (StringUtils.isNotBlank(result)) {
-            try {
-                return objectMapper.readValue(result, Map.class);
-            } catch (IOException e) {
-                return null;
-            }
-        }
-        return null;
-    }
-}

+ 0 - 19
mybatis-plus/src/test/resources/mapper/ResultMapEntityMapper.xml

@@ -1,19 +0,0 @@
-<?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.baomidou.mybatisplus.test.mysql.mapper.commons.ResultMapEntityMapper">
-
-    <resultMap id="baseResult" type="com.baomidou.mybatisplus.test.mysql.entity.ResultMapEntity">
-        <id column="id" property="id"/>
-        <result column="column1" property="column1"/>
-        <result column="column2" property="column2"/>
-        <result column="column3" property="column3"/>
-    </resultMap>
-
-    <resultMap id="resultChildren1" type="com.baomidou.mybatisplus.test.mysql.entity.ResultMapEntity"
-               extends="baseResult">
-        <result column="column_1234" property="column4"/>
-        <result column="list" property="list" typeHandler="com.baomidou.mybatisplus.test.mysql.type.ListTypeHandler"/>
-        <result column="map" property="map" typeHandler="com.baomidou.mybatisplus.test.mysql.type.MapTypeHandler"/>
-        <result column="map" property="mapp" typeHandler="com.baomidou.mybatisplus.test.mysql.type.JsonTypeHandler"/>
-    </resultMap>
-</mapper>

+ 0 - 9
mybatis-plus/src/test/resources/mysql/spring-test-mysql.xml

@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns="http://www.springframework.org/schema/beans"
-       xmlns:context="http://www.springframework.org/schema/context"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
-       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
-
-    <context:component-scan base-package="com.baomidou.mybatisplus.test.mysql.config"/>
-</beans>

+ 0 - 63
mybatis-plus/src/test/resources/mysql/test_data.ddl.sql

@@ -1,63 +0,0 @@
-drop table if exists common_data;
-drop table if exists common_logic_data;
-drop table if exists mysql_data;
-drop table if exists result_map_entity;
-
-CREATE TABLE common_data
-(
-    id         BIGINT primary key NOT NULL AUTO_INCREMENT,
-    test_int   integer,
-    test_str   varchar(50),
-    c_time     datetime,
-    u_time     datetime,
-    version    integer default 0,
-    test_enum  integer,
-    test_enum2 integer,
-    tenant_id  bigint
-) ENGINE = innodb
-  DEFAULT CHARSET = utf8;
-
-CREATE TABLE common_logic_data
-(
-    id       BIGINT primary key,
-    test_int integer,
-    test_str varchar(50),
-    c_time   datetime,
-    u_time   datetime,
-    deleted  tinyint default 0,
-    version  integer default 0
-) ENGINE = innodb
-  DEFAULT CHARSET = utf8;
-
-CREATE TABLE mysql_data
-(
-    id         BIGINT auto_increment primary key,
-    `order`    integer,
-    `group`    integer,
-    test_str   varchar(255),
-    lambda_str varchar(255) default ''
-) ENGINE = innodb
-  DEFAULT CHARSET = utf8;
-
-CREATE TABLE result_map_entity
-(
-    id          BIGINT primary key,
-    column1     varchar(200) default '1',
-    column2     varchar(200) default '2',
-    column3     varchar(200) default '3',
-    column_1234 varchar(200) default '4',
-    list        varchar(200),
-    map         varchar(200),
-    mapp        varchar(200)
-) ENGINE = innodb
-  DEFAULT CHARSET = utf8;
-
-INSERT INTO common_data (id, test_int, test_str, c_time, test_enum, tenant_id)
-VALUES (666666666, 25, 'test', now(), 1, 1);
-INSERT INTO common_data (id, test_int, test_str, c_time, test_enum, tenant_id)
-VALUES (777777777, 25, 'test', now(), 1, 1);
-
-INSERT INTO common_logic_data (id, test_int, test_str, c_time)
-VALUES (666666666, 25, 'test', now());
-INSERT INTO common_logic_data (id, test_int, test_str, c_time)
-VALUES (777777777, 25, 'test', now());