@SpringBootTest @RunWith(SpringJUnit4ClassRunner.class) public class HelloTest { @Autowired private SysDictionaryDao dictionaryDao; @Before public void before(){ TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(),""), SysDictionary.class); } @Test public void hello () { System.out.println("Hello Spring Boot Test"); String pCode = "1" ; Long pid = 1L ; updateSysCode(pCode,pid); } public void updateSysCode(String pCode,Long pid){ List<SysDictionary> list = dictionaryDao.selectList(new LambdaQueryWrapper<SysDictionary>().eq(SysDictionary::getPid,pid).orderByAsc(SysDictionary::getId)); if(CollectionUtils.isEmpty(list)){ return; } int i = 1000; for(SysDictionary dictionary :list){ dictionary.setCode(pCode+i+""); dictionaryDao.updateById(dictionary); i++; updateSysCode(dictionary.getCode(),dictionary.getId()); } } }
标签:dictionary,单元测试,pid,SysDictionary,updateSysCode,pCode,编写,public From: https://www.cnblogs.com/lewisat/p/17807583.html