@Test public void multipleDelete() throws Exception { List<User> userList = new ArrayList<>(); for (int i = 0; i < 10; i++) { String s = UUID.randomUUID().toString(); String email = s.substring(s.length() - 4) + "@celess.cn"; String pwd = MD5Util.getMD5("123456789"); int i1 = userMapper.addUser(email, pwd); if (i1 == 0) { continue; } userList.add(userMapper.findByEmail(email)); if (i == 9) { userMapper.setUserRole(userMapper.findByEmail(email).getId(), "admin"); } } List<Long> idList = new ArrayList<>(); userList.forEach(user -> idList.add(user.getId())); System.out.println("id :: == > " + idList.toString()); mockMvc.perform(delete("/admin/user/delete").content(idList.toString()).contentType("application/json")) .andDo(result -> assertEquals(HAVE_NOT_LOG_IN.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code))); mockMvc.perform(delete("/admin/user/delete").content(idList.toString()).contentType("application/json").header("Authorization", userLogin())) .andDo(result -> assertEquals(PERMISSION_ERROR.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code))); mockMvc.perform(delete("/admin/user/delete").content(idList.toString()).contentType("application/json").header("Authorization", adminLogin())) .andDo(result -> { JSONObject object = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), object.getInt(Code)); JSONArray jsonArray = object.getJSONArray(Result); jsonArray.forEach(o -> { JSONObject json = JSONObject.fromObject(o); assertTrue(idList.contains((long) json.getInt("id"))); boolean status = json.getBoolean("status"); if (json.containsKey("msg")) assertFalse(status); else assertTrue(status); }); }); }
@DeleteMapping("/admin/user/delete") public Response multipleDelete(@RequestBody Integer[] ids) { return ResponseUtil.success(userService.deleteUser(ids)); }
UserController { @DeleteMapping("/admin/user/delete") public Response multipleDelete(@RequestBody Integer[] ids) { return ResponseUtil.success(userService.deleteUser(ids)); } }
UserController { @DeleteMapping("/admin/user/delete") public Response multipleDelete(@RequestBody Integer[] ids) { return ResponseUtil.success(userService.deleteUser(ids)); }  }
UserController { @DeleteMapping("/admin/user/delete") public Response multipleDelete(@RequestBody Integer[] ids) { return ResponseUtil.success(userService.deleteUser(ids)); }  @PostMapping("/login") Response login(@RequestBody LoginReq loginReq); @PostMapping("/registration") Response registration(@RequestParam("email") String email,
                                 @RequestParam("password") String password); @GetMapping("/logout") Response logout(); @PutMapping("/user/userInfo/update") Response updateInfo(String desc, String displayName); @GetMapping("/user/userInfo") Response getUserInfo(); @PostMapping("/user/imgUpload") @ResponseBody Response upload(@RequestParam("file") MultipartFile file); @PostMapping("/sendResetPwdEmail") Response sendResetPwdEmail(@RequestParam("email") String email); @PostMapping("/sendVerifyEmail") Response sendVerifyEmail(@RequestParam("email") String email); @PostMapping("/emailVerify") Response emailVerify(@RequestParam("verifyId") String verifyId,
                                @RequestParam("email") String mail); @PostMapping("/resetPwd") Response resetPwd(@RequestParam("verifyId") String verifyId,
                             @RequestParam("email") String email,
                             @RequestParam("pwd") String pwd); @DeleteMapping("/admin/user/delete") Response multipleDelete(@RequestBody Integer[] ids); @DeleteMapping("/admin/user/delete/{id}") Response delete(@PathVariable("id") Integer id); @PutMapping("/admin/user") Response updateInfoByAdmin(@RequestBody UserReq user); @GetMapping("/admin/users") Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count); @GetMapping("/emailStatus/{email}") Response getEmailStatus(@PathVariable("email") String email); }
UserController { @DeleteMapping("/admin/user/delete") public Response multipleDelete(@RequestBody Integer[] ids) { return ResponseUtil.success(userService.deleteUser(ids)); }  @PostMapping("/login") Response login(@RequestBody LoginReq loginReq); @PostMapping("/registration") Response registration(@RequestParam("email") String email,
                                 @RequestParam("password") String password); @GetMapping("/logout") Response logout(); @PutMapping("/user/userInfo/update") Response updateInfo(String desc, String displayName); @GetMapping("/user/userInfo") Response getUserInfo(); @PostMapping("/user/imgUpload") @ResponseBody Response upload(@RequestParam("file") MultipartFile file); @PostMapping("/sendResetPwdEmail") Response sendResetPwdEmail(@RequestParam("email") String email); @PostMapping("/sendVerifyEmail") Response sendVerifyEmail(@RequestParam("email") String email); @PostMapping("/emailVerify") Response emailVerify(@RequestParam("verifyId") String verifyId,
                                @RequestParam("email") String mail); @PostMapping("/resetPwd") Response resetPwd(@RequestParam("verifyId") String verifyId,
                             @RequestParam("email") String email,
                             @RequestParam("pwd") String pwd); @DeleteMapping("/admin/user/delete") Response multipleDelete(@RequestBody Integer[] ids); @DeleteMapping("/admin/user/delete/{id}") Response delete(@PathVariable("id") Integer id); @PutMapping("/admin/user") Response updateInfoByAdmin(@RequestBody UserReq user); @GetMapping("/admin/users") Response getAllUser(@RequestParam("page") int pageNum, @RequestParam("count") int count); @GetMapping("/emailStatus/{email}") Response getEmailStatus(@PathVariable("email") String email);  }