|
@@ -1,5 +1,22 @@
|
|
|
package com.baomidou.mybatisplus.test.mysql;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
+import org.junit.Assert;
|
|
|
+import org.junit.BeforeClass;
|
|
|
+import org.junit.FixMethodOrder;
|
|
|
+import org.junit.Test;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
+import org.junit.runners.MethodSorters;
|
|
|
+import org.springframework.test.context.ContextConfiguration;
|
|
|
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
@@ -16,17 +33,6 @@ 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;
|
|
|
-import org.junit.FixMethodOrder;
|
|
|
-import org.junit.Test;
|
|
|
-import org.junit.runner.RunWith;
|
|
|
-import org.junit.runners.MethodSorters;
|
|
|
-import org.springframework.test.context.ContextConfiguration;
|
|
|
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-import java.util.*;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -349,4 +355,17 @@ public class MysqlTestDataMapperTest {
|
|
|
commonMapper.selectList(Wrappers.lambdaQuery(new CommonData().setTestInt(12)).orderByAsc(CommonData::getCreateDatetime));
|
|
|
commonLogicMapper.selectList(Wrappers.lambdaQuery(new CommonLogicData().setTestInt(12)).orderByAsc(CommonLogicData::getCreateDatetime));
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ public void d11_testWrapperCustomSql() {
|
|
|
+ // 1. 只有 order by 或者 last
|
|
|
+ mysqlMapper.getAll(Wrappers.<MysqlData>query().lambda().orderByDesc(MysqlData::getOrder).last("limit 1"));
|
|
|
+ // 2. 什么都没有情况
|
|
|
+ mysqlMapper.getAll(Wrappers.emptyWrapper());
|
|
|
+ // 3. 只有 where 条件
|
|
|
+ mysqlMapper.getAll(Wrappers.lambdaQuery(new MysqlData()).eq(MysqlData::getGroup, 1));
|
|
|
+ // 4. 有 where 条件 也有 last 条件
|
|
|
+ mysqlMapper.getAll(Wrappers.lambdaQuery(new MysqlData()).eq(MysqlData::getGroup, 1).last("limit 1"));
|
|
|
+ }
|
|
|
}
|