增加
1.控制层
@PostMapping("/addStudentPlus") public Result addStudentPlus(@RequestBody Liststudent){ studnetService.addStudentPlus(student); return new Result(true, MessageConstant.ADD_CHECKGROUP_FAIL); }
2.业务层
@Override public void addStudentPlus(Liststudent) { for (int i = 0; i < 1000; i++) { student.add(new Student((UUID.randomUUID().toString().substring(0,5)),"dada","ohdoa","dad",new Teacher("1","1","1","1"))); } studentDao.addStudentPlus(student); }
3.xml
void addStudentPlus(@Param("student") Liststudent);
insert into student(id,name,address) values (#{emp.id},#{emp.name},#{emp.address})
3.2批量增加的第二种写法
insert into dict ( id , parent_id , name , value , dict_code ) values ( #{item.id} , #{item.parentId} , #{item.name} , #{item.value} , #{item.dictCode} )
4.postman
删除
1.控制层
@PostMapping("/deleteByIds") public Result deleteByIds(String s){ Boolean flag=true; if (s.contains("-")){ flag= checkItemService.deleteByIds(Arrays.asList(s.split("-"))); }else checkItemService.deleteById(Integer.parseInt(s)); return new Result(flag,"删除成功!"); }
2.业务层
@Override public Boolean deleteByIds(ListasList) { return checkItemDao.deleteByIds(asList); }
3.xml
Boolean deleteByIds(@Param("asList") ListasList);
delete from student #{item}
4.postman