瀏覽代碼

mysql测试修正

miemie 7 年之前
父節點
當前提交
5507f62bdf
共有 23 個文件被更改,包括 244 次插入654 次删除
  1. 2 2
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/SampleTest.java
  2. 0 17
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/BaseEntity.java
  3. 7 19
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/CommonData.java
  4. 37 0
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/CommonLogicData.java
  5. 0 45
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/LogicTestData.java
  6. 20 0
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/mysql/MysqlData.java
  7. 3 8
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/pg/PgData.java
  8. 0 11
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/mapper/LogicTestDataMapper.java
  9. 0 11
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/mapper/PgTestDataMapper.java
  10. 5 5
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/mapper/commons/CommonDataMapper.java
  11. 11 0
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/mapper/commons/CommonLogicDataMapper.java
  12. 11 0
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/mapper/mysql/MysqlDataMapper.java
  13. 11 0
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/mapper/pg/PgDataMapper.java
  14. 0 9
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/service/ILogicTestDataService.java
  15. 0 13
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/service/impl/LogicTestDataServiceImpl.java
  16. 0 11
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/H2UserMapperTest.java
  17. 105 188
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/MysqlTestDataMapperTest.java
  18. 2 3
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/config/MybatisPlusConfig.java
  19. 0 279
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/postgres/PostgresTestDataMapperTest.java
  20. 1 2
      mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/postgres/config/MybatisPlusConfig.java
  21. 1 2
      mybatis-plus/src/test/resources/mysql/spring-test-mysql.xml
  22. 27 28
      mybatis-plus/src/test/resources/mysql/test_data.ddl.sql
  23. 1 1
      mybatis-plus/src/test/resources/postgres/spring-test-postgres.xml

+ 2 - 2
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/SampleTest.java

@@ -2,7 +2,7 @@ package com.baomidou.mybatisplus.test;
 
 import com.baomidou.mybatisplus.core.metadata.TableInfo;
 import com.baomidou.mybatisplus.core.toolkit.TableInfoHelper;
-import com.baomidou.mybatisplus.test.base.entity.LogicTestData;
+import com.baomidou.mybatisplus.test.base.entity.CommonLogicData;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.junit.Test;
 
@@ -13,7 +13,7 @@ public class SampleTest {
 
     @Test
     public void testTableInfoHelper2() {
-        TableInfo info = TableInfoHelper.initTableInfo(null, LogicTestData.class);
+        TableInfo info = TableInfoHelper.initTableInfo(null, CommonLogicData.class);
 //        System.out.println("----------- AllInsertSqlColumn -----------");
 //        System.out.println(info.getAllInsertSqlColumn());
 //        System.out.println("----------- AllInsertSqlProperty -----------");

+ 0 - 17
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/BaseEntity.java

@@ -1,17 +0,0 @@
-package com.baomidou.mybatisplus.test.base.entity;
-
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-/**
- * 父类
- *
- * @author miemie
- * @since 2018-08-06
- */
-@Data
-@Accessors(chain = true)
-public class BaseEntity {
-
-    private Long id;
-}

+ 7 - 19
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/TestData.java → mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/CommonData.java

@@ -2,43 +2,31 @@ package com.baomidou.mybatisplus.test.base.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 lombok.Data;
-import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 
-import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.time.LocalTime;
 
 /**
  * 包含功能:
- * 1.继承父类字段     验证无误
- * 2.自动填充        验证无误
- * 3.乐观锁          验证无误
- * 4.多租户          验证无误
+ * 1.自动填充        验证无误
+ * 2.乐观锁          验证无误
+ * 3.多租户          验证无误
  *
  * @author meimie
  * @since 2018/6/7
  */
 @Data
-@EqualsAndHashCode(callSuper = true)
 @Accessors(chain = true)
-@TableName(value = "tb_test_data")
-public class TestData extends BaseEntity {
+public class CommonData {
 
+    private Long id;
     private Integer testInt;
     private String testStr;
-    private Double testDouble;
-    private Boolean testBoolean;
-    private LocalDate testDate;
-    private LocalTime testTime;
-    private LocalDateTime testDateTime;
-    private LocalDateTime testTimestamp;
-    @TableField(fill = FieldFill.INSERT)
+    @TableField(value = "c_time", fill = FieldFill.INSERT)
     private LocalDateTime createDatetime;
-    @TableField(fill = FieldFill.UPDATE)
+    @TableField(value = "u_time", fill = FieldFill.UPDATE)
     private LocalDateTime updateDatetime;
 
     @Version

+ 37 - 0
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/CommonLogicData.java

@@ -0,0 +1,37 @@
+package com.baomidou.mybatisplus.test.base.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.乐观锁          验证无误
+ *
+ * @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
+    private Integer deleted;
+
+    @Version
+    private Integer version;
+}

+ 0 - 45
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/LogicTestData.java

@@ -1,45 +0,0 @@
-package com.baomidou.mybatisplus.test.base.entity;
-
-import com.baomidou.mybatisplus.annotation.*;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.Accessors;
-
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-
-/**
- * 包含功能:
- * 1.继承父类字段     验证无误
- * 2.自动填充        验证无误
- * 3.逻辑删除        验证无误
- * 4.乐观锁          验证无误
- *
- * @author meimie
- * @since 2018/6/7
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@Accessors(chain = true)
-@TableName(value = "tb_test_data_logic")
-public class LogicTestData extends BaseEntity {
-
-    private Integer testInt;
-    private String testStr;
-    private Double testDouble;
-    private Boolean testBoolean;
-    private LocalDate testDate;
-    private LocalTime testTime;
-    private LocalDateTime testDateTime;
-    private LocalDateTime testTimestamp;
-    @TableField(fill = FieldFill.INSERT)
-    private LocalDateTime createDatetime;
-    @TableField(fill = FieldFill.UPDATE)
-    private LocalDateTime updateDatetime;
-    @TableLogic
-    private Boolean deleted;
-
-    @Version
-    private Integer version;
-}

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

@@ -0,0 +1,20 @@
+package com.baomidou.mybatisplus.test.base.entity.mysql;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author miemie
+ * @since 2018-08-18
+ */
+@Data
+@Accessors(chain = true)
+public class MysqlData {
+
+    private Long id;
+    @TableField("`order`")
+    private Integer order;
+    @TableField("`group`")
+    private Integer group;
+}

+ 3 - 8
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/PgTestData.java → mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/entity/pg/PgData.java

@@ -1,11 +1,8 @@
-package com.baomidou.mybatisplus.test.base.entity;
+package com.baomidou.mybatisplus.test.base.entity.pg;
 
 import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.ToString;
 import lombok.experimental.Accessors;
 
 import java.time.LocalDateTime;
@@ -15,12 +12,10 @@ import java.time.LocalDateTime;
  * @since 2018-08-06
  */
 @Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
 @Accessors(chain = true)
-@TableName(value = "tb_only_pg_test_data")
-public class PgTestData extends BaseEntity {
+public class PgData {
 
+    private Long id;
     @TableField(value = "age", el = "dataAge, jdbcType=INTEGER")
     private Integer dataAge;
     @TableField(value = "c_datetime", fill = FieldFill.INSERT)

+ 0 - 11
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/mapper/LogicTestDataMapper.java

@@ -1,11 +0,0 @@
-package com.baomidou.mybatisplus.test.base.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.test.base.entity.LogicTestData;
-
-/**
- * @author miemie
- * @since 2018-07-06
- */
-public interface LogicTestDataMapper extends BaseMapper<LogicTestData> {
-}

+ 0 - 11
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/mapper/PgTestDataMapper.java

@@ -1,11 +0,0 @@
-package com.baomidou.mybatisplus.test.base.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.test.base.entity.PgTestData;
-
-/**
- * @author miemie
- * @since 2018-08-06
- */
-public interface PgTestDataMapper extends BaseMapper<PgTestData> {
-}

+ 5 - 5
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/mapper/TestDataMapper.java → mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/mapper/commons/CommonDataMapper.java

@@ -1,8 +1,8 @@
-package com.baomidou.mybatisplus.test.base.mapper;
+package com.baomidou.mybatisplus.test.base.mapper.commons;
 
 import com.baomidou.mybatisplus.annotation.SqlParser;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.test.base.entity.TestData;
+import com.baomidou.mybatisplus.test.base.entity.CommonData;
 import org.apache.ibatis.annotations.ResultType;
 import org.apache.ibatis.annotations.Select;
 
@@ -12,10 +12,10 @@ import java.util.List;
  * @author miemie
  * @since 2018/6/7
  */
-public interface TestDataMapper extends BaseMapper<TestData> {
+public interface CommonDataMapper extends BaseMapper<CommonData> {
 
     @SqlParser(filter = true)
-    @ResultType(TestData.class)
+    @ResultType(CommonData.class)
     @Select("select * from tb_test_data")
-    List<TestData> getAllNoTenant();
+    List<CommonData> getAllNoTenant();
 }

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

@@ -0,0 +1,11 @@
+package com.baomidou.mybatisplus.test.base.mapper.commons;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.test.base.entity.CommonLogicData;
+
+/**
+ * @author miemie
+ * @since 2018-07-06
+ */
+public interface CommonLogicDataMapper extends BaseMapper<CommonLogicData> {
+}

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

@@ -0,0 +1,11 @@
+package com.baomidou.mybatisplus.test.base.mapper.mysql;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.test.base.entity.mysql.MysqlData;
+
+/**
+ * @author miemie
+ * @since 2018-08-18
+ */
+public interface MysqlDataMapper extends BaseMapper<MysqlData> {
+}

+ 11 - 0
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/mapper/pg/PgDataMapper.java

@@ -0,0 +1,11 @@
+package com.baomidou.mybatisplus.test.base.mapper.pg;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.test.base.entity.pg.PgData;
+
+/**
+ * @author miemie
+ * @since 2018-08-06
+ */
+public interface PgDataMapper extends BaseMapper<PgData> {
+}

+ 0 - 9
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/service/ILogicTestDataService.java

@@ -1,9 +0,0 @@
-package com.baomidou.mybatisplus.test.base.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.baomidou.mybatisplus.test.base.entity.LogicTestData;
-
-public interface ILogicTestDataService extends IService<LogicTestData> {
-
-
-}

+ 0 - 13
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/base/service/impl/LogicTestDataServiceImpl.java

@@ -1,13 +0,0 @@
-package com.baomidou.mybatisplus.test.base.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.test.base.entity.LogicTestData;
-import com.baomidou.mybatisplus.test.base.mapper.LogicTestDataMapper;
-import com.baomidou.mybatisplus.test.base.service.ILogicTestDataService;
-import org.springframework.stereotype.Service;
-
-
-@Service
-public class LogicTestDataServiceImpl extends ServiceImpl<LogicTestDataMapper, LogicTestData> implements ILogicTestDataService {
-
-}

+ 0 - 11
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/H2UserMapperTest.java

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.test.base.entity.TestData;
 import com.baomidou.mybatisplus.test.h2.config.H2Db;
 import com.baomidou.mybatisplus.test.h2.entity.mapper.H2UserMapper;
 import com.baomidou.mybatisplus.test.h2.entity.persistent.H2User;
@@ -140,16 +139,6 @@ public class H2UserMapperTest extends BaseTest {
         Assert.assertTrue(CollectionUtils.isNotEmpty(userMapper.selectMaps(new QueryWrapper<>(new H2User().setAge(18)))));
     }
 
-
-    @Test
-    public void update() {
-        UpdateWrapper uw = new UpdateWrapper<TestData>();
-        uw.set("age", 1);
-        uw.eq("test_id", 101L);
-        userMapper.update(new H2User().setName("咩咩"), uw);
-    }
-
-
     @Test
     public void delete() {
         userMapper.delete(new QueryWrapper<>(new H2User().setAge(2))

+ 105 - 188
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/MysqlTestDataMapperTest.java

@@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.test.base.entity.LogicTestData;
-import com.baomidou.mybatisplus.test.base.entity.TestData;
-import com.baomidou.mybatisplus.test.base.mapper.LogicTestDataMapper;
-import com.baomidou.mybatisplus.test.base.mapper.TestDataMapper;
-import com.baomidou.mybatisplus.test.base.service.ILogicTestDataService;
+import com.baomidou.mybatisplus.test.base.entity.CommonData;
+import com.baomidou.mybatisplus.test.base.entity.CommonLogicData;
+import com.baomidou.mybatisplus.test.base.entity.mysql.MysqlData;
+import com.baomidou.mybatisplus.test.base.mapper.commons.CommonDataMapper;
+import com.baomidou.mybatisplus.test.base.mapper.commons.CommonLogicDataMapper;
+import com.baomidou.mybatisplus.test.base.mapper.mysql.MysqlDataMapper;
 import com.baomidou.mybatisplus.test.mysql.config.MysqlDb;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -19,10 +21,6 @@ import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
@@ -41,12 +39,11 @@ import java.util.Map;
 public class MysqlTestDataMapperTest {
 
     @Resource
-    private TestDataMapper mapper;
+    private CommonDataMapper commonMapper;
     @Resource
-    private LogicTestDataMapper logicMapper;
-
+    private CommonLogicDataMapper commonLogicMapper;
     @Resource
-    private ILogicTestDataService logicTestDataService;
+    private MysqlDataMapper mysqlMapper;
 
     @BeforeClass
     public static void init() throws Exception {
@@ -55,249 +52,169 @@ public class MysqlTestDataMapperTest {
 
     @Test
     public void insertForeach() {
-        LocalDateTime nowDateTime = LocalDateTime.now();
-        LocalDate nowDate = nowDateTime.toLocalDate();
-        LocalTime nowTime = nowDateTime.toLocalTime();
-        for (int i = 0; i < 20; i++) {
-            mapper.insert(new TestData().setTestInt(i).setTestStr(String.format("第%s条数据", i))
-                .setTestDouble(BigDecimal.valueOf(3.3).multiply(BigDecimal.valueOf(i)).doubleValue())
-                .setTestBoolean((i + 3) % 2 == 0).setTestDate(nowDate)
-                .setTestTime(nowTime).setTestDateTime(nowDateTime));
-            logicMapper.insert(new LogicTestData().setTestInt(i).setTestStr(String.format("第%s条数据", i))
-                .setTestDouble(BigDecimal.valueOf(3.3).multiply(BigDecimal.valueOf(i)).doubleValue())
-                .setTestBoolean((i + 3) % 2 == 0).setTestDate(nowDate)
-                .setTestTime(nowTime).setTestDateTime(nowDateTime));
+        for (int i = 1; i < 30; i++) {
+            Long id = (long) i;
+            commonMapper.insert(new CommonData().setTestInt(i).setTestStr(String.format("第%s条数据", i)).setId(id));
+            commonLogicMapper.insert(new CommonLogicData().setTestInt(i).setTestStr(String.format("第%s条数据", i)).setId(id));
+            mysqlMapper.insert(new MysqlData().setOrder(1).setGroup(2).setId(id));
         }
     }
 
     @Test
     public void deleteById() {
-        mapper.deleteById(1014132604940615682L);
-        logicMapper.deleteById(1014132604940615682L);
+        Assert.assertEquals(1, commonMapper.deleteById(1L));
+        Assert.assertEquals(1, commonLogicMapper.deleteById(1L));
+        Assert.assertEquals(1, mysqlMapper.deleteById(1L));
     }
 
     @Test
     public void deleteByMap() {
         Map<String, Object> map = new HashMap<>();
-        map.put("id", 1014361515785568258L);
+        map.put("id", 2);
         map.put("test_int", 5);
-        mapper.deleteByMap(map);
-        logicMapper.deleteByMap(map);
-    }
-
-    @Test
-    public void other() {
-        logicMapper.update(new LogicTestData().setDeleted(true), null);
+        Assert.assertEquals(0, commonMapper.deleteByMap(map));
+        Assert.assertEquals(0, commonLogicMapper.deleteByMap(map));
+        Assert.assertEquals(0, mysqlMapper.deleteByMap(map));
     }
 
     @Test
     public void delete() {
-        mapper.delete(new QueryWrapper<TestData>().lambda()
-            .eq(TestData::getId, 1014132604940615682L)
-            .eq(TestData::getTestInt, 1));
-        logicMapper.delete(new QueryWrapper<LogicTestData>().lambda()
-            .eq(LogicTestData::getId, 1014132604940615682L)
-            .eq(LogicTestData::getTestInt, 1));
+        Assert.assertEquals(1, commonMapper.delete(new QueryWrapper<CommonData>().lambda()
+            .eq(CommonData::getId, 2L)
+            .eq(CommonData::getTestInt, 2)));
+        Assert.assertEquals(1, commonLogicMapper.delete(new QueryWrapper<CommonLogicData>().lambda()
+            .eq(CommonLogicData::getId, 2L)
+            .eq(CommonLogicData::getTestInt, 2)));
+        Assert.assertEquals(1, mysqlMapper.delete(new QueryWrapper<MysqlData>().lambda()
+            .eq(MysqlData::getId, 2L)
+            .eq(MysqlData::getOrder, 2)));
     }
 
     @Test
     public void deleteBatchIds() {
-        List<Long> ids = Arrays.asList(1014132604940615682L, 1014132604940615652L);
-        mapper.deleteBatchIds(ids);
-        logicMapper.deleteBatchIds(ids);
+        List<Long> ids = Arrays.asList(3L, 4L);
+        Assert.assertEquals(1, commonMapper.deleteBatchIds(ids));
+        Assert.assertEquals(1, commonLogicMapper.deleteBatchIds(ids));
+        Assert.assertEquals(1, mysqlMapper.deleteBatchIds(ids));
     }
 
     @Test
-    public void updateTimeIssue() {
-//        mapper.updateById(new TestData().setId(1014132604940615682L).setTestInt(1111111111));
-        LogicTestData et = new LogicTestData()
-            .setTestInt(9991122)
-            .setVersion(19);
-        System.out.println("====1=====>>>" + JSON.toJSONString(et, true));
-        boolean r = logicTestDataService.saveOrUpdate(et);
-        System.out.println("====2-1==r==>>>" + r);
-        System.out.println("====2-2=====>>>" + JSON.toJSONString(et, true));
+    public void updateById() {
+        Assert.assertEquals(1, commonMapper.updateById(new CommonData().setId(5L).setTestInt(555)));
+        Assert.assertEquals(1, commonLogicMapper.updateById(new CommonLogicData().setId(5L).setTestInt(555)));
+        Assert.assertEquals(1, mysqlMapper.updateById(new MysqlData().setId(5L).setOrder(555)));
     }
 
     @Test
     public void optimisticUpdateById() {
-//        mapper.updateById(new TestData().setId(1014132604940615682L).setTestInt(1111111111));
-        LogicTestData et = new LogicTestData()
-            .setTestInt(999)
-            .setVersion(17);
-        System.out.println("====1=====>>>" + JSON.toJSONString(et, true));
-        int r = logicMapper.updateById(et);
-        System.out.println("====2-1==r==>>>" + r);
-        System.out.println("====2-2=====>>>" + JSON.toJSONString(et, true));
-    }
-
-    @Test
-    public void updateById() {
-        mapper.updateById(new TestData().setTestInt(1111111111));
-        logicMapper.updateById(new LogicTestData().setTestInt(1111111111));
+        Assert.assertEquals(1, commonMapper.updateById(new CommonData().setId(5L).setTestInt(556)
+            .setVersion(0)));
     }
 
     @Test
     public void update() {
-        // type 1
-        mapper.update(new TestData(), null);
-        logicMapper.update(new LogicTestData(), null);
-        // type 2
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .set("test_int", 5));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .set("test_int", 5));
-//        // type 3
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .set("test_int", 5).eq("id", 1014361515554881538L));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .set("test_int", 5).eq("id", 1014361515554881538L));
-//        // type 4
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .eq("id", 1014361515554881538L));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .eq("id", 1014361515554881538L));
-//        // type 5
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .setEntity(new TestData().setTestInt(1)));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .setEntity(new LogicTestData().setTestInt(1)));
-//        // type 6
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .setEntity(new TestData().setTestInt(1))
-            .eq("id", 1014361515554881538L));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .setEntity(new LogicTestData().setTestInt(1))
-            .eq("id", 1014361515554881538L));
-//        // type 7
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .setEntity(new TestData().setTestInt(1))
-            .set("test_int", 55555)
-            .eq("id", 1014361515554881538L));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .setEntity(new LogicTestData().setTestInt(1))
-            .set("test_int", 55555)
-            .eq("id", 1014361515554881538L));
+        Assert.assertEquals(1, commonMapper.update(
+            new CommonData().setTestInt(666),
+            new UpdateWrapper<CommonData>().lambda().eq(CommonData::getId, 6L)
+                .eq(CommonData::getTestInt, 6)));
+        Assert.assertEquals(1, commonLogicMapper.update(
+            new CommonLogicData().setTestInt(666),
+            new UpdateWrapper<CommonLogicData>().lambda().eq(CommonLogicData::getId, 6L)
+                .eq(CommonLogicData::getTestInt, 6)));
+        Assert.assertEquals(1, mysqlMapper.update(
+            new MysqlData().setOrder(666),
+            new UpdateWrapper<MysqlData>().lambda().eq(MysqlData::getId, 6L)
+                .eq(MysqlData::getOrder, 6)));
     }
 
     @Test
     public void getAllNoTenant() {
-        mapper.getAllNoTenant();
+        commonMapper.getAllNoTenant();
     }
 
     @Test
     public void selectById() {
-        mapper.selectById(1L);
-        logicMapper.selectById(1L);
+        long id = 6L;
+        Assert.assertNotNull(commonMapper.selectById(id));
+        Assert.assertNotNull(commonLogicMapper.selectById(id));
+        Assert.assertNotNull(mysqlMapper.selectById(id));
     }
 
     @Test
     public void selectBatchIds() {
-        List<Long> ids = Arrays.asList(1014132604940615682L, 1014132604940615652L);
-        mapper.selectBatchIds(ids);
-        logicMapper.selectBatchIds(ids);
+        List<Long> ids = Arrays.asList(7L, 8L);
+        Assert.assertTrue(CollectionUtils.isNotEmpty(commonMapper.selectBatchIds(ids)));
+        Assert.assertTrue(CollectionUtils.isNotEmpty(commonLogicMapper.selectBatchIds(ids)));
+        Assert.assertTrue(CollectionUtils.isNotEmpty(mysqlMapper.selectBatchIds(ids)));
     }
 
     @Test
     public void selectByMap() {
         Map<String, Object> map = new HashMap<>();
-        map.put("id", 1L);
-        map.put("test_int", 1);
-        mapper.selectByMap(map);
-        logicMapper.selectByMap(map);
+        map.put("id", 9L);
+        map.put("test_int", 9);
+        Assert.assertTrue(CollectionUtils.isNotEmpty(commonMapper.selectByMap(map)));
+        Assert.assertTrue(CollectionUtils.isNotEmpty(commonLogicMapper.selectByMap(map)));
+        Assert.assertTrue(CollectionUtils.isNotEmpty(mysqlMapper.selectByMap(map)));
     }
 
     @Test
     public void selectOne() {
-        mapper.selectOne(new QueryWrapper<TestData>().lambda()
-            .eq(TestData::getId, 1L).eq(TestData::getTestInt, 1));
-        logicMapper.selectOne(new QueryWrapper<LogicTestData>().lambda()
-            .eq(LogicTestData::getId, 1L).eq(LogicTestData::getTestInt, 1));
+        Assert.assertNotNull(commonMapper.selectOne(new QueryWrapper<CommonData>().lambda()
+            .eq(CommonData::getId, 10L).eq(CommonData::getTestInt, 10)));
+        Assert.assertNotNull(commonLogicMapper.selectOne(new QueryWrapper<CommonLogicData>().lambda()
+            .eq(CommonLogicData::getId, 10L).eq(CommonLogicData::getTestInt, 10)));
+        Assert.assertNotNull(mysqlMapper.selectOne(new QueryWrapper<MysqlData>().lambda()
+            .eq(MysqlData::getId, 10L).eq(MysqlData::getOrder, 10)));
     }
 
     @Test
     public void selectList() {
-        mapper.selectList(new QueryWrapper<TestData>().lambda()
-            .eq(TestData::getId, 1L).eq(TestData::getTestInt, 1));
-        logicMapper.selectList(new QueryWrapper<LogicTestData>().lambda()
-            .eq(LogicTestData::getId, 1L).eq(LogicTestData::getTestInt, 1));
-        logicMapper.selectList(null);
-    }
-
-    @Test
-    public void commonSelectList() {
-        println(mapper.selectList(new QueryWrapper<TestData>()
-            .eq("id", 1L)
-            .like("test_str", 1)
-            .between("test_double", 1L, 2L)));
-    }
-
-    @Test
-    public void specialSelectList() {
-        println(mapper.selectList(new QueryWrapper<TestData>().lambda()
-            .nested(i -> i.eq(TestData::getId, 1L))
-            .or(i -> i.between(TestData::getTestDouble, 1L, 2L))
-            .or(i -> i.eq(TestData::getTestInt, 1)
-                .or().eq(TestData::getTestDate, 1)
-            )
-            .eq(TestData::getTestBoolean, true)
-            .eq(TestData::getTestDate, LocalDate.of(2008, 8, 8))
-            .between(TestData::getTestDate, LocalDate.of(2008, 1, 1),
-                LocalDate.of(2008, 12, 12))));
+        Assert.assertTrue(CollectionUtils.isNotEmpty(commonMapper.selectList(new QueryWrapper<CommonData>()
+            .lambda().eq(CommonData::getId, 10L).eq(CommonData::getTestInt, 10))));
+        Assert.assertTrue(CollectionUtils.isNotEmpty(commonLogicMapper.selectList(new QueryWrapper<CommonLogicData>()
+            .lambda().eq(CommonLogicData::getId, 10L).eq(CommonLogicData::getTestInt, 10))));
+        Assert.assertTrue(CollectionUtils.isNotEmpty(mysqlMapper.selectList(new QueryWrapper<MysqlData>()
+            .lambda().eq(MysqlData::getId, 10L).eq(MysqlData::getOrder, 10))));
     }
 
     @Test
     public void selectPage() {
-        IPage<TestData> page = new Page<>();
+        IPage<CommonData> page = new Page<>();
         page.setSize(5).setCurrent(1);
-        IPage<TestData> dataPage = mapper.selectPage(page, null);
+        IPage<CommonData> dataPage = commonMapper.selectPage(page, null);
         Assert.assertSame(dataPage, page);
-        System.out.println(String.format("total = {%s}", dataPage.getTotal()));
-        System.out.println(String.format("data.size = {%s}", dataPage.getRecords().size()));
-        println(page.getRecords());
-        System.out.println(JSON.toJSONString(page));
+        Assert.assertNotEquals(0L, dataPage.getTotal());
+        Assert.assertNotEquals(0, dataPage.getRecords().size());
+        Assert.assertTrue(CollectionUtils.isNotEmpty(dataPage.getRecords()));
+        System.out.println(JSON.toJSONString(dataPage));
 
-        IPage<LogicTestData> logicPage = new Page<>();
-        logicPage.setSize(5).setCurrent(1);
-        IPage<LogicTestData> logicDataPage = logicMapper.selectPage(logicPage, null);
+        IPage<CommonData> logicPage = new Page<>();
+        page.setSize(5).setCurrent(1);
+        IPage<CommonData> logicDataPage = commonMapper.selectPage(page, null);
         Assert.assertSame(logicDataPage, logicPage);
-        System.out.println(String.format("total = {%s}", logicDataPage.getTotal()));
-        System.out.println(String.format("data.size = {%s}", logicDataPage.getRecords().size()));
-        println(logicDataPage.getRecords());
+        Assert.assertNotEquals(0L, logicDataPage.getTotal());
+        Assert.assertNotEquals(0, logicDataPage.getRecords().size());
+        Assert.assertTrue(CollectionUtils.isNotEmpty(logicDataPage.getRecords()));
         System.out.println(JSON.toJSONString(logicDataPage));
 
-    }
-
-    @Test
-    public void testIn() {
-        println(mapper.selectList(new QueryWrapper<TestData>()
-//            .in("test_int", Arrays.asList(1, 2, 3))//ok
-//                .notIn("test_int", Arrays.asList(1, 2, 3)//ok
-//                .in("test_int", 1, 2, 3)//ok
-//                .notIn("test_int", 1, 2, 3)//ok
-                .inSql("test_int", "1,2,3")//ok
-                .notInSql("test_int", "2,3")//ok
-        ));
-    }
-
-    @Test
-    public void testExists() {
-        println(mapper.selectList(new QueryWrapper<TestData>()
-            .exists("select * from tb_test_data")//ok
-            .or()
-            .notExists("select * from tb_test_data")//ok
-        ));
-        /* exists 连着用是可行的 */
+        IPage<CommonData> mysqlPage = new Page<>();
+        page.setSize(5).setCurrent(1);
+        IPage<CommonData> mysqlDataPage = commonMapper.selectPage(page, null);
+        Assert.assertSame(mysqlDataPage, mysqlPage);
+        Assert.assertNotEquals(0L, mysqlDataPage.getTotal());
+        Assert.assertNotEquals(0, mysqlDataPage.getRecords().size());
+        Assert.assertTrue(CollectionUtils.isNotEmpty(mysqlDataPage.getRecords()));
+        System.out.println(JSON.toJSONString(mysqlDataPage));
     }
 
     @Test
     public void testApply() {
-        println(mapper.selectList(new QueryWrapper<TestData>()
-            .apply("test_int = 1")
-        ));
-    }
-
-    private <T> void println(List<T> list) {
-        list.forEach(System.out::println);
+        Assert.assertTrue(CollectionUtils.isNotEmpty(commonMapper.selectList(new QueryWrapper<CommonData>()
+            .apply("test_int = 12"))));
+        Assert.assertTrue(CollectionUtils.isNotEmpty(commonLogicMapper.selectList(new QueryWrapper<CommonLogicData>()
+            .apply("test_int = 12"))));
+        Assert.assertTrue(CollectionUtils.isNotEmpty(mysqlMapper.selectList(new QueryWrapper<MysqlData>()
+            .apply("order = 12"))));
     }
 }

+ 2 - 3
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/mysql/config/MybatisPlusConfig.java

@@ -31,7 +31,7 @@ import java.util.List;
  * @since 2017/4/1
  */
 @Configuration
-@MapperScan("com.baomidou.mybatisplus.test.base.mapper")
+@MapperScan({"com.baomidou.mybatisplus.test.base.mapper.commons", "com.baomidou.mybatisplus.test.base.mapper.mysql"})
 public class MybatisPlusConfig {
 
     @Bean("mybatisSqlSession")
@@ -41,7 +41,6 @@ public class MybatisPlusConfig {
         /* 数据源 */
         sqlSessionFactory.setDataSource(dataSource);
         /* entity扫描,mybatis的Alias功能 */
-        sqlSessionFactory.setTypeAliasesPackage("com.baomidou.mybatisplus.test.base.entity");
         MybatisConfiguration configuration = new MybatisConfiguration();
         configuration.setJdbcTypeForNull(JdbcType.NULL);
         /* 驼峰转下划线 */
@@ -90,7 +89,7 @@ public class MybatisPlusConfig {
             @Override
             public boolean doTableFilter(String tableName) {
                 // 这里可以判断是否过滤表
-                return "tb_test_data_logic".equals(tableName);
+                return "common_logic_data".equals(tableName) || "mysql_data".equals(tableName);
             }
         });
         sqlParserList.add(tenantSqlParser);

+ 0 - 279
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/postgres/PostgresTestDataMapperTest.java

@@ -1,33 +1,9 @@
 package com.baomidou.mybatisplus.test.postgres;
 
-import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.test.base.entity.LogicTestData;
-import com.baomidou.mybatisplus.test.base.entity.PgTestData;
-import com.baomidou.mybatisplus.test.base.entity.TestData;
-import com.baomidou.mybatisplus.test.base.mapper.LogicTestDataMapper;
-import com.baomidou.mybatisplus.test.base.mapper.PgTestDataMapper;
-import com.baomidou.mybatisplus.test.base.mapper.TestDataMapper;
-import com.baomidou.mybatisplus.test.base.service.ILogicTestDataService;
-import org.junit.Assert;
-import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 /**
  * <p>
  * Mybatis Plus mysql Junit Test
@@ -40,259 +16,4 @@ import java.util.Map;
 @ContextConfiguration(locations = {"classpath:postgres/spring-test-postgres.xml"})
 public class PostgresTestDataMapperTest {
 
-    @Resource
-    private TestDataMapper mapper;
-    @Resource
-    private LogicTestDataMapper logicMapper;
-    @Resource
-    private PgTestDataMapper pgMapper;
-
-    @Resource
-    private ILogicTestDataService logicTestDataService;
-
-//    @BeforeClass
-//    public static void init() throws IOException, SQLException {
-//        PostgresDb.initMysqlData();
-//    }
-
-    @Test
-    public void insertForeach() {
-        LocalDateTime nowDateTime = LocalDateTime.now();
-        LocalDate nowDate = nowDateTime.toLocalDate();
-        LocalTime nowTime = nowDateTime.toLocalTime();
-        for (int i = 0; i < 20; i++) {
-            mapper.insert(new TestData().setTestInt(i).setTestStr(String.format("第%s条数据", i))
-                .setTestDouble(BigDecimal.valueOf(3.3).multiply(BigDecimal.valueOf(i)).doubleValue())
-                .setTestBoolean((i + 3) % 2 == 0).setTestDate(nowDate)
-                .setTestTime(nowTime).setTestDateTime(nowDateTime));
-            logicMapper.insert(new LogicTestData().setTestInt(i).setTestStr(String.format("第%s条数据", i))
-                .setTestDouble(BigDecimal.valueOf(3.3).multiply(BigDecimal.valueOf(i)).doubleValue())
-                .setTestBoolean((i + 3) % 2 == 0).setTestDate(nowDate)
-                .setTestTime(nowTime).setTestDateTime(nowDateTime));
-            pgMapper.insert(new PgTestData().setDataAge(i));
-        }
-    }
-
-    @Test
-    public void deleteById() {
-        mapper.deleteById(1014132604940615682L);
-        logicMapper.deleteById(1014132604940615682L);
-    }
-
-    @Test
-    public void deleteByMap() {
-        Map<String, Object> map = new HashMap<>();
-        map.put("id", 1014361515785568258L);
-        map.put("test_int", 5);
-        mapper.deleteByMap(map);
-        logicMapper.deleteByMap(map);
-    }
-
-    @Test
-    public void delete() {
-        mapper.delete(new QueryWrapper<TestData>().lambda()
-            .eq(TestData::getId, 1014132604940615682L)
-            .eq(TestData::getTestInt, 1));
-        logicMapper.delete(new QueryWrapper<LogicTestData>().lambda()
-            .eq(LogicTestData::getId, 1014132604940615682L)
-            .eq(LogicTestData::getTestInt, 1));
-    }
-
-    @Test
-    public void deleteBatchIds() {
-        List<Long> ids = Arrays.asList(1014132604940615682L, 1014132604940615652L);
-        mapper.deleteBatchIds(ids);
-        logicMapper.deleteBatchIds(ids);
-    }
-
-    @Test
-    public void updateTimeIssue() {
-//        mapper.updateById(new TestData().setId(1014132604940615682L).setTestInt(1111111111));
-        LogicTestData et = new LogicTestData()
-            .setTestInt(9991122)
-            .setVersion(19);
-        System.out.println("====1=====>>>" + JSON.toJSONString(et, true));
-        boolean r = logicTestDataService.saveOrUpdate(et);
-        System.out.println("====2-1==r==>>>" + r);
-        System.out.println("====2-2=====>>>" + JSON.toJSONString(et, true));
-    }
-
-    @Test
-    public void optimisticUpdateById() {
-//        mapper.updateById(new TestData().setId(1014132604940615682L).setTestInt(1111111111));
-        LogicTestData et = new LogicTestData()
-            .setTestInt(999)
-            .setVersion(17);
-        System.out.println("====1=====>>>" + JSON.toJSONString(et, true));
-        int r = logicMapper.updateById(et);
-        System.out.println("====2-1==r==>>>" + r);
-        System.out.println("====2-2=====>>>" + JSON.toJSONString(et, true));
-    }
-
-    @Test
-    public void updateById() {
-        mapper.updateById(new TestData().setTestInt(1111111111));
-        logicMapper.updateById(new LogicTestData().setTestInt(1111111111));
-    }
-
-    @Test
-    public void update() {
-        // type 1
-        mapper.update(new TestData(), null);
-        logicMapper.update(new LogicTestData(), null);
-        // type 2
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .set("test_int", 5));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .set("test_int", 5));
-//        // type 3
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .set("test_int", 5).eq("id", 1014361515554881538L));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .set("test_int", 5).eq("id", 1014361515554881538L));
-//        // type 4
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .eq("id", 1014361515554881538L));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .eq("id", 1014361515554881538L));
-//        // type 5
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .setEntity(new TestData().setTestInt(1)));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .setEntity(new LogicTestData().setTestInt(1)));
-//        // type 6
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .setEntity(new TestData().setTestInt(1))
-            .eq("id", 1014361515554881538L));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .setEntity(new LogicTestData().setTestInt(1))
-            .eq("id", 1014361515554881538L));
-//        // type 7
-        mapper.update(new TestData(), new UpdateWrapper<TestData>()
-            .setEntity(new TestData().setTestInt(1))
-            .set("test_int", 55555)
-            .eq("id", 1014361515554881538L));
-        logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
-            .setEntity(new LogicTestData().setTestInt(1))
-            .set("test_int", 55555)
-            .eq("id", 1014361515554881538L));
-    }
-
-    @Test
-    public void selectById() {
-        mapper.selectById(1L);
-        logicMapper.selectById(1L);
-        pgMapper.selectById(1L);
-    }
-
-    @Test
-    public void selectBatchIds() {
-        List<Long> ids = Arrays.asList(1014132604940615682L, 1014132604940615652L);
-        mapper.selectBatchIds(ids);
-        logicMapper.selectBatchIds(ids);
-    }
-
-    @Test
-    public void selectByMap() {
-        Map<String, Object> map = new HashMap<>();
-        map.put("id", 1L);
-        map.put("test_int", 1);
-        mapper.selectByMap(map);
-        logicMapper.selectByMap(map);
-    }
-
-    @Test
-    public void selectOne() {
-        mapper.selectOne(new QueryWrapper<TestData>().lambda()
-            .eq(TestData::getId, 1L).eq(TestData::getTestInt, 1));
-        logicMapper.selectOne(new QueryWrapper<LogicTestData>().lambda()
-            .eq(LogicTestData::getId, 1L).eq(LogicTestData::getTestInt, 1));
-    }
-
-    @Test
-    public void selectList() {
-        mapper.selectList(new QueryWrapper<TestData>().lambda()
-            .eq(TestData::getId, 1L).eq(TestData::getTestInt, 1));
-        logicMapper.selectList(new QueryWrapper<LogicTestData>().lambda()
-            .eq(LogicTestData::getId, 1L).eq(LogicTestData::getTestInt, 1));
-        logicMapper.selectList(null);
-        println(pgMapper.selectList(null));
-    }
-
-    @Test
-    public void commonSelectList() {
-        println(mapper.selectList(new QueryWrapper<TestData>()
-            .eq("id", 1L)
-            .like("test_str", 1)
-            .between("test_double", 1L, 2L)));
-    }
-
-    @Test
-    public void specialSelectList() {
-        println(mapper.selectList(new QueryWrapper<TestData>().lambda()
-            .nested(i -> i.eq(TestData::getId, 1L))
-            .or(i -> i.between(TestData::getTestDouble, 1L, 2L))
-            .or(i -> i.eq(TestData::getTestInt, 1)
-                .or().eq(TestData::getTestDate, LocalDate.now())
-            )
-            .eq(TestData::getTestBoolean, true)
-            .eq(TestData::getTestDate, LocalDate.of(2008, 8, 8))
-            .between(TestData::getTestDate, LocalDate.of(2008, 1, 1),
-                LocalDate.of(2008, 12, 12))));
-    }
-
-    @Test
-    public void selectPage() {
-        IPage<TestData> page = new Page<>();
-        page.setSize(5).setCurrent(1);
-        IPage<TestData> dataPage = mapper.selectPage(page, null);
-        Assert.assertSame(dataPage, page);
-        System.out.println(String.format("total = {%s}", dataPage.getTotal()));
-        System.out.println(String.format("data.size = {%s}", dataPage.getRecords().size()));
-        println(page.getRecords());
-        System.out.println(JSON.toJSONString(page));
-
-        IPage<LogicTestData> logicPage = new Page<>();
-        logicPage.setSize(5).setCurrent(1);
-        IPage<LogicTestData> logicDataPage = logicMapper.selectPage(logicPage, null);
-        Assert.assertSame(logicDataPage, logicPage);
-        System.out.println(String.format("total = {%s}", logicDataPage.getTotal()));
-        System.out.println(String.format("data.size = {%s}", logicDataPage.getRecords().size()));
-        println(logicDataPage.getRecords());
-        System.out.println(JSON.toJSONString(logicDataPage));
-
-    }
-
-    @Test
-    public void testIn() {
-        println(mapper.selectList(new QueryWrapper<TestData>()
-//            .in("test_int", Arrays.asList(1, 2, 3))//ok
-//                .notIn("test_int", Arrays.asList(1, 2, 3)//ok
-//                .in("test_int", 1, 2, 3)//ok
-//                .notIn("test_int", 1, 2, 3)//ok
-                .inSql("test_int", "1,2,3")//ok
-                .notInSql("test_int", "2,3")//ok
-        ));
-    }
-
-    @Test
-    public void testExists() {
-        println(mapper.selectList(new QueryWrapper<TestData>()
-            .exists("select * from tb_test_data")//ok
-            .or()
-            .notExists("select * from tb_test_data")//ok
-        ));
-        /* exists 连着用是可行的 */
-    }
-
-    @Test
-    public void testApply() {
-        println(mapper.selectList(new QueryWrapper<TestData>()
-            .apply("test_int = 1")
-        ));
-    }
-
-    private <T> void println(List<T> list) {
-        list.forEach(System.out::println);
-    }
 }

+ 1 - 2
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/postgres/config/MybatisPlusConfig.java

@@ -24,7 +24,7 @@ import javax.sql.DataSource;
  * @since 2017/4/1
  */
 @Configuration
-@MapperScan("com.baomidou.mybatisplus.test.base.mapper")
+@MapperScan({"com.baomidou.mybatisplus.test.base.mapper.commons", "com.baomidou.mybatisplus.test.base.mapper.ps"})
 public class MybatisPlusConfig {
 
     @Bean("mybatisSqlSession")
@@ -33,7 +33,6 @@ public class MybatisPlusConfig {
         /* 数据源 */
         sqlSessionFactory.setDataSource(dataSource);
         /* entity扫描,mybatis的Alias功能 */
-        sqlSessionFactory.setTypeAliasesPackage("com.baomidou.mybatisplus.test.base.entity");
         MybatisConfiguration configuration = new MybatisConfiguration();
         configuration.setJdbcTypeForNull(JdbcType.NULL);
         /* 驼峰转下划线 */

+ 1 - 2
mybatis-plus/src/test/resources/mysql/spring-test-mysql.xml

@@ -5,6 +5,5 @@
        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;com.baomidou.mybatisplus.test.base.service"/>
+    <context:component-scan base-package="com.baomidou.mybatisplus.test.mysql.config"/>
 </beans>

+ 27 - 28
mybatis-plus/src/test/resources/mysql/test_data.ddl.sql

@@ -1,35 +1,34 @@
-CREATE TABLE IF NOT EXISTS tb_test_data_logic (
-    id              BIGINT primary key,
-    test_int        integer,
-    test_str        varchar(50),
-    test_double     double,
-    test_boolean    tinyint(1),
-    test_date       date,
-    test_time       time,
-    test_date_time  datetime,
-    test_timestamp  timestamp,
-    create_datetime datetime,
-    update_datetime datetime,
-    deleted         tinyint(1) default 0,
-    version         integer    default 0
+drop table if exists common_data;
+drop table if exists common_logic_data;
+drop table if exists mysql_data;
+CREATE TABLE common_data (
+    id        BIGINT primary key,
+    test_int  integer,
+    test_str  varchar(50),
+    c_time    datetime,
+    u_time    datetime,
+    version   integer default 0,
+    tenant_id bigint
 )
     ENGINE = innodb
 DEFAULT CHARSET = utf8;
 
-CREATE TABLE IF NOT EXISTS tb_test_data (
-    id              BIGINT primary key,
-    test_int        integer,
-    test_str        varchar(50),
-    test_double     double,
-    test_boolean    tinyint(1),
-    test_date       date,
-    test_time       time,
-    test_date_time  datetime,
-    test_timestamp  timestamp,
-    create_datetime datetime,
-    update_datetime datetime,
-    version         integer default 0,
-    tenant_id       bigint
+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 primary key,
+    ` order ` integer,
+    ` group ` integer
 )
     ENGINE = innodb
 DEFAULT CHARSET = utf8;

+ 1 - 1
mybatis-plus/src/test/resources/postgres/spring-test-postgres.xml

@@ -6,5 +6,5 @@
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
 
     <context:component-scan
-        base-package="com.baomidou.mybatisplus.test.postgres.config;com.baomidou.mybatisplus.test.base.service"/>
+        base-package="com.baomidou.mybatisplus.test.postgres.config"/>
 </beans>