浏览代码

[格式] 测试代码格式

miemie 6 年之前
父节点
当前提交
7d95630852

+ 24 - 29
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/h2/service/impl/H2UserServiceImpl.java

@@ -15,21 +15,19 @@
  */
  */
 package com.baomidou.mybatisplus.test.h2.service.impl;
 package com.baomidou.mybatisplus.test.h2.service.impl;
 
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
 import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
 import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.test.h2.entity.mapper.H2UserMapper;
 import com.baomidou.mybatisplus.test.h2.entity.mapper.H2UserMapper;
 import com.baomidou.mybatisplus.test.h2.entity.persistent.H2User;
 import com.baomidou.mybatisplus.test.h2.entity.persistent.H2User;
 import com.baomidou.mybatisplus.test.h2.service.IH2UserService;
 import com.baomidou.mybatisplus.test.h2.service.IH2UserService;
+import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
 /**
 /**
  * <p>
  * <p>
  * Service层测试
  * Service层测试
@@ -41,12 +39,9 @@ import org.springframework.transaction.annotation.Transactional;
 @Service
 @Service
 public class H2UserServiceImpl extends ServiceImpl<H2UserMapper, H2User> implements IH2UserService {
 public class H2UserServiceImpl extends ServiceImpl<H2UserMapper, H2User> implements IH2UserService {
 
 
-    @Autowired
-    private H2UserMapper userMapper;
-    
     @Override
     @Override
     public int myInsert(String name, int version) {
     public int myInsert(String name, int version) {
-        return userMapper.myInsertWithNameVersion(name, version);
+        return baseMapper.myInsertWithNameVersion(name, version);
     }
     }
 
 
     @Override
     @Override
@@ -54,7 +49,7 @@ public class H2UserServiceImpl extends ServiceImpl<H2UserMapper, H2User> impleme
         H2User user = new H2User();
         H2User user = new H2User();
         user.setName(name);
         user.setName(name);
         user.setVersion(version);
         user.setVersion(version);
-        return userMapper.myInsertWithParam(user);
+        return baseMapper.myInsertWithParam(user);
     }
     }
 
 
     @Override
     @Override
@@ -62,17 +57,17 @@ public class H2UserServiceImpl extends ServiceImpl<H2UserMapper, H2User> impleme
         H2User user = new H2User();
         H2User user = new H2User();
         user.setName(name);
         user.setName(name);
         user.setVersion(version);
         user.setVersion(version);
-        return userMapper.myInsertWithoutParam(user);
+        return baseMapper.myInsertWithoutParam(user);
     }
     }
 
 
     @Override
     @Override
     public int myUpdate(Long id, String name) {
     public int myUpdate(Long id, String name) {
-        return userMapper.myUpdateWithNameId(id, name);
+        return baseMapper.myUpdateWithNameId(id, name);
     }
     }
 
 
     @Override
     @Override
     public List<H2User> queryWithParamInSelectStatememt(Map<String, Object> param) {
     public List<H2User> queryWithParamInSelectStatememt(Map<String, Object> param) {
-        return userMapper.selectUserWithParamInSelectStatememt(param);
+        return baseMapper.selectUserWithParamInSelectStatememt(param);
     }
     }
 
 
     @Override
     @Override
@@ -84,45 +79,45 @@ public class H2UserServiceImpl extends ServiceImpl<H2UserMapper, H2User> impleme
 
 
     @Override
     @Override
     public int selectCountWithParamInSelectItems(Map<String, Object> param) {
     public int selectCountWithParamInSelectItems(Map<String, Object> param) {
-        return userMapper.selectCountWithParamInSelectItems(param);
+        return baseMapper.selectCountWithParamInSelectItems(param);
     }
     }
 
 
     @Override
     @Override
     public List<Map> mySelectMaps() {
     public List<Map> mySelectMaps() {
-        return userMapper.mySelectMaps();
+        return baseMapper.mySelectMaps();
     }
     }
 
 
     @Override
     @Override
     @Transactional(rollbackFor = RuntimeException.class)
     @Transactional(rollbackFor = RuntimeException.class)
     public void testBatchTransactional() {
     public void testBatchTransactional() {
-        saveBatch(Arrays.asList(new H2User("batch1",0),new H2User("batch2",0),new H2User("batch3",0)));
-        saveBatch(Arrays.asList(new H2User("batch4",0),new H2User("batch5",0),new H2User("batch6",0)));
+        saveBatch(Arrays.asList(new H2User("batch1", 0), new H2User("batch2", 0), new H2User("batch3", 0)));
+        saveBatch(Arrays.asList(new H2User("batch4", 0), new H2User("batch5", 0), new H2User("batch6", 0)));
         throw new MybatisPlusException("测试批量插入事务回滚");
         throw new MybatisPlusException("测试批量插入事务回滚");
     }
     }
 
 
     @Override
     @Override
     @Transactional(rollbackFor = RuntimeException.class)
     @Transactional(rollbackFor = RuntimeException.class)
     public void testSimpleTransactional() {
     public void testSimpleTransactional() {
-        save(new H2User("simple1",0));
-        save(new H2User("simple2",0));
+        save(new H2User("simple1", 0));
+        save(new H2User("simple2", 0));
         throw new MybatisPlusException("测试普通插入事务回滚");
         throw new MybatisPlusException("测试普通插入事务回滚");
     }
     }
-    
-    
+
+
     @Override
     @Override
     @Transactional(rollbackFor = RuntimeException.class)
     @Transactional(rollbackFor = RuntimeException.class)
     public void testSaveOrUpdateBatchTransactional() {
     public void testSaveOrUpdateBatchTransactional() {
-        saveOrUpdateBatch(Arrays.asList(new H2User("savOrUpdate1",0),new H2User("savOrUpdate2",0),new H2User("savOrUpdate3",0)),1);
-        saveOrUpdateBatch(Arrays.asList(new H2User("savOrUpdate4",0),new H2User("savOrUpdate5",0),new H2User("savOrUpdate6",0)),1);
+        saveOrUpdateBatch(Arrays.asList(new H2User("savOrUpdate1", 0), new H2User("savOrUpdate2", 0), new H2User("savOrUpdate3", 0)), 1);
+        saveOrUpdateBatch(Arrays.asList(new H2User("savOrUpdate4", 0), new H2User("savOrUpdate5", 0), new H2User("savOrUpdate6", 0)), 1);
         throw new MybatisPlusException("测试普通插入事务回滚");
         throw new MybatisPlusException("测试普通插入事务回滚");
     }
     }
-    
+
     @Override
     @Override
     @Transactional(rollbackFor = RuntimeException.class)
     @Transactional(rollbackFor = RuntimeException.class)
     public void testSimpleAndBatchTransactional() {
     public void testSimpleAndBatchTransactional() {
-        save(new H2User("simpleAndBatchTx1",0));
-        saveBatch(Arrays.asList(new H2User("simpleAndBatchTx2",0),new H2User("simpleAndBatchTx3",0),new H2User("simpleAndBatchTx4",0)),1);
-        saveOrUpdateBatch(Arrays.asList(new H2User("simpleAndBatchTx5",0),new H2User("simpleAndBatchTx6",0),new H2User("simpleAndBatchTx7",0)),1);
+        save(new H2User("simpleAndBatchTx1", 0));
+        saveBatch(Arrays.asList(new H2User("simpleAndBatchTx2", 0), new H2User("simpleAndBatchTx3", 0), new H2User("simpleAndBatchTx4", 0)), 1);
+        saveOrUpdateBatch(Arrays.asList(new H2User("simpleAndBatchTx5", 0), new H2User("simpleAndBatchTx6", 0), new H2User("simpleAndBatchTx7", 0)), 1);
         throw new MybatisPlusException("测试事务回滚");
         throw new MybatisPlusException("测试事务回滚");
     }
     }
 }
 }