|
@@ -19,7 +19,6 @@ import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.junit.runner.RunWith;
|
|
import org.springframework.test.context.ContextConfiguration;
|
|
import org.springframework.test.context.ContextConfiguration;
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
@@ -71,14 +70,12 @@ public class MysqlTestDataMapperTest {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- @Transactional
|
|
|
|
public void deleteById() {
|
|
public void deleteById() {
|
|
mapper.deleteById(1014132604940615682L);
|
|
mapper.deleteById(1014132604940615682L);
|
|
logicMapper.deleteById(1014132604940615682L);
|
|
logicMapper.deleteById(1014132604940615682L);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- @Transactional
|
|
|
|
public void deleteByMap() {
|
|
public void deleteByMap() {
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
map.put("id", 1014361515785568258L);
|
|
map.put("id", 1014361515785568258L);
|
|
@@ -88,15 +85,16 @@ public class MysqlTestDataMapperTest {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- @Transactional
|
|
|
|
public void delete() {
|
|
public void delete() {
|
|
mapper.delete(new QueryWrapper<TestData>().lambda()
|
|
mapper.delete(new QueryWrapper<TestData>().lambda()
|
|
.eq(TestData::getId, 1014132604940615682L)
|
|
.eq(TestData::getId, 1014132604940615682L)
|
|
.eq(TestData::getTestInt, 1));
|
|
.eq(TestData::getTestInt, 1));
|
|
|
|
+ logicMapper.delete(new QueryWrapper<LogicTestData>().lambda()
|
|
|
|
+ .eq(LogicTestData::getId, 1014132604940615682L)
|
|
|
|
+ .eq(LogicTestData::getTestInt, 1));
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- @Transactional
|
|
|
|
public void deleteBatchIds() {
|
|
public void deleteBatchIds() {
|
|
List<Long> ids = Arrays.asList(1014132604940615682L, 1014132604940615652L);
|
|
List<Long> ids = Arrays.asList(1014132604940615682L, 1014132604940615652L);
|
|
mapper.deleteBatchIds(ids);
|
|
mapper.deleteBatchIds(ids);
|
|
@@ -104,53 +102,94 @@ public class MysqlTestDataMapperTest {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- @Transactional
|
|
|
|
- public void updateByIdTest() {
|
|
|
|
|
|
+ public void updateById() {
|
|
mapper.updateById(new TestData().setId(1014132604940615682L).setTestInt(1111111111));
|
|
mapper.updateById(new TestData().setId(1014132604940615682L).setTestInt(1111111111));
|
|
|
|
+ logicMapper.updateById(new LogicTestData().setId(1014132604940615682L).setTestInt(1111111111));
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- @Transactional
|
|
|
|
- public void updateTest() {
|
|
|
|
|
|
+ public void update() {
|
|
// type 1
|
|
// type 1
|
|
mapper.update(new TestData(), null);
|
|
mapper.update(new TestData(), null);
|
|
|
|
+ logicMapper.update(new LogicTestData(), null);
|
|
// type 2
|
|
// type 2
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
.set("test_int", 5));
|
|
.set("test_int", 5));
|
|
- // type 3
|
|
|
|
|
|
+ logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
|
|
|
|
+ .set("test_int", 5));
|
|
|
|
+// // type 3
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
.set("test_int", 5).eq("id", 1014361515554881538L));
|
|
.set("test_int", 5).eq("id", 1014361515554881538L));
|
|
- // type 4
|
|
|
|
|
|
+ logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
|
|
|
|
+ .set("test_int", 5).eq("id", 1014361515554881538L));
|
|
|
|
+// // type 4
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
.eq("id", 1014361515554881538L));
|
|
.eq("id", 1014361515554881538L));
|
|
- // type 5
|
|
|
|
|
|
+ logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
|
|
|
|
+ .eq("id", 1014361515554881538L));
|
|
|
|
+// // type 5
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
.setEntity(new TestData().setTestInt(1)));
|
|
.setEntity(new TestData().setTestInt(1)));
|
|
- // type 6
|
|
|
|
|
|
+ logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
|
|
|
|
+ .setEntity(new LogicTestData().setTestInt(1)));
|
|
|
|
+// // type 6
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
.setEntity(new TestData().setTestInt(1))
|
|
.setEntity(new TestData().setTestInt(1))
|
|
.eq("id", 1014361515554881538L));
|
|
.eq("id", 1014361515554881538L));
|
|
- // type 7
|
|
|
|
|
|
+ logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
|
|
|
|
+ .setEntity(new LogicTestData().setTestInt(1))
|
|
|
|
+ .eq("id", 1014361515554881538L));
|
|
|
|
+// // type 7
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
mapper.update(new TestData(), new UpdateWrapper<TestData>()
|
|
.setEntity(new TestData().setTestInt(1))
|
|
.setEntity(new TestData().setTestInt(1))
|
|
.set("test_int", 55555)
|
|
.set("test_int", 55555)
|
|
.eq("id", 1014361515554881538L));
|
|
.eq("id", 1014361515554881538L));
|
|
|
|
+ logicMapper.update(new LogicTestData(), new UpdateWrapper<LogicTestData>()
|
|
|
|
+ .setEntity(new LogicTestData().setTestInt(1))
|
|
|
|
+ .set("test_int", 55555)
|
|
|
|
+ .eq("id", 1014361515554881538L));
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- @Transactional
|
|
|
|
public void selectById() {
|
|
public void selectById() {
|
|
mapper.selectById(1L);
|
|
mapper.selectById(1L);
|
|
|
|
+ logicMapper.selectById(1L);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- @Transactional
|
|
|
|
public void selectBatchIds() {
|
|
public void selectBatchIds() {
|
|
- mapper.selectBatchIds(Arrays.asList(1014132604940615682L, 1014132604940615652L));
|
|
|
|
|
|
+ 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);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- @Transactional
|
|
|
|
public void commonSelectList() {
|
|
public void commonSelectList() {
|
|
println(mapper.selectList(new QueryWrapper<TestData>()
|
|
println(mapper.selectList(new QueryWrapper<TestData>()
|
|
.eq("id", 1L)
|
|
.eq("id", 1L)
|
|
@@ -159,7 +198,6 @@ public class MysqlTestDataMapperTest {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- @Transactional
|
|
|
|
public void specialSelectList() {
|
|
public void specialSelectList() {
|
|
println(mapper.selectList(new QueryWrapper<TestData>().lambda()
|
|
println(mapper.selectList(new QueryWrapper<TestData>().lambda()
|
|
.nested(i -> i.eq(TestData::getId, 1L))
|
|
.nested(i -> i.eq(TestData::getId, 1L))
|
|
@@ -174,23 +212,6 @@ public class MysqlTestDataMapperTest {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- @Transactional
|
|
|
|
- public void update() {
|
|
|
|
- mapper.update(new TestData().setId(1L).setTestStr("123123"),
|
|
|
|
- new UpdateWrapper<TestData>().eq("id", 1L));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- @Transactional
|
|
|
|
- public void selectByMap() {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("id", 1L);
|
|
|
|
- map.put("test_int", 1);
|
|
|
|
- println(mapper.selectByMap(map));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- @Transactional
|
|
|
|
public void selectPage() {
|
|
public void selectPage() {
|
|
IPage<TestData> page = new Page<>();
|
|
IPage<TestData> page = new Page<>();
|
|
page.setSize(5).setCurrent(1);
|
|
page.setSize(5).setCurrent(1);
|