第1步:实例化UserDAO对象
@Autowired(required = false)
private UserDAO dao;
第2步:使用MyBatisPlus实现基本的CRUD
@RequestMapping("/t2")
public int insertUser(){
int count = dao.insert(new User(null, "tom", "123"));
return count;
}
@RequestMapping("/t3")
public List<User> t3(){
List<User> users = dao.selectList(null);
return users;
}
@RequestMapping("/t4")
public User t4(){
User u = dao.selectById(1001l);
return u;
}
@RequestMapping("/t5")
public int t5(){
int count = dao.updateById(new User(1592405843226775554L, "mike", "321"));
return count;
}
@RequestMapping("/t6")
public int t6(){
int count = dao.deleteById(1001l);
return count;
}
@RequestMapping("/t7")
public int t7(){
int count = dao.deleteBatchIds(Arrays.asList(1592419001718865921L, 1592419001144246274L));
return count;
}