使用@Delete注解批量删除
1、控制器调用
// test // http://localhost:3000/function/test // 删除操作+按钮权限 @Transactional @GetMapping("/test") public JSONObject testBatch() { // Arrays.asList(1, 2, 3) JSONObject result = new JSONObject(); try { functionMapper.batchDeleteOperations(Arrays.asList(15L,16L)); result.put("status",200); result.put("message","删除成功"); } catch (Exception ex) { ex.printStackTrace(); result.put("status",ResultCode.ERROR); result.put("message","删除失败"); } return result; }
2、接口实现
// 通过批量PARENT_ID批量删除操作 @Delete("<script>" + "delete from TBL_FUNCTION WHERE PARENT_ID IN " +" <foreach collection='list' item='id' separator=',' open='(' close=')'> " + " #{id}" + " </foreach>" +"</script>") int batchDeleteOperations(List<Long> ids);
3、效果图
删除前:
删除后: