@Test publicvoidtestSelect(){ User user = new User(); QueryWrapper<User> userQueryWrapper = new QueryWrapper<>(); userQueryWrapper.le("age","20"); List<User> users = user.selectList(userQueryWrapper);
for (User user1 : users) { System.out.println(user1); } }
新增
1 2 3 4 5 6 7 8 9 10 11 12 13
@Test publicvoidtestInsert(){ User user = new User(); user.setName("刘备"); user.setAge(30); user.setPassword("123456"); user.setUserName("liubei"); user.setEmail("liubei@itcast.cn");
boolean insert = user.insert();
System.out.println(insert); }
返回插入是否成功
更新
1 2 3 4 5 6 7 8 9
@Test publicvoidtestUpdate(){ User user = new User(); user.setId(5L); user.setAge(35);