@Test public void deleteTest() throws Exception { Comment c = new Comment(); c.setArticleID(-1L); c.setType(true); c.setAuthorID(2L); c.setDate(new Date()); c.setPid(-1L); commentMapper.insert(c); Comment comment = commentMapper.getLastestComment(); long id = comment.getId(); assertNotEquals(0, id); String token = userLogin(); mockMvc.perform(delete("/user/comment/del?id=" + id).header("Authorization", token)).andDo(result -> { JSONObject object = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), object.getInt(Code)); assertTrue(object.getBoolean(Result)); }); mockMvc.perform(delete("/user/comment/del?id=" + id).header("Authorization", token)).andDo(result -> { JSONObject object = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(COMMENT_NOT_EXIST.getCode(), object.getInt(Code)); }); }
@DeleteMapping("/user/comment/del") public Response delete(@RequestParam("id") long id) { return ResponseUtil.success(commentService.delete(id)); }
CommentController { @DeleteMapping("/user/comment/del") public Response delete(@RequestParam("id") long id) { return ResponseUtil.success(commentService.delete(id)); } }
CommentController { @DeleteMapping("/user/comment/del") public Response delete(@RequestParam("id") long id) { return ResponseUtil.success(commentService.delete(id)); }  }
CommentController { @DeleteMapping("/user/comment/del") public Response delete(@RequestParam("id") long id) { return ResponseUtil.success(commentService.delete(id)); }  @PostMapping("/user/comment/create") Response addOne(@RequestBody CommentReq reqBody); @DeleteMapping("/user/comment/del") Response delete(@RequestParam("id") long id); @PutMapping("/user/comment/update") Response update(@RequestBody CommentReq reqBody); @GetMapping("/comments") Response commentsOfArticle(@RequestParam("articleId") long articleId,
                                      @RequestParam(value = "count", required = false, defaultValue = "10") int count,
                                      @RequestParam(value = "page", required = false, defaultValue = "1") int page); @GetMapping("/comment/pid/{pid}") Response retrievePage(@PathVariable("pid") long pid,
                                 @RequestParam(value = "count", required = false, defaultValue = "10") int count,
                                 @RequestParam(value = "page", required = false, defaultValue = "1") int page); @GetMapping("/leaveMsg") Response retrievePageOfLeaveMsg(@RequestParam(value = "count", required = false, defaultValue = "10") int count,
                                           @RequestParam(value = "page", required = false, defaultValue = "1") int page); @GetMapping("/admin/comment/type/{type}") Response retrievePageAdmin(
            @PathVariable("type") int isComment,
            @RequestParam(value = "count", required = false, defaultValue = "10") int count,
            @RequestParam(value = "page", required = false, defaultValue = "1") int page); @GetMapping("/user/comment/type/{type}") Response retrievePageByAuthor(
            @PathVariable(value = "type") int isComment,
            @RequestParam(value = "count", required = false, defaultValue = "10") int count,
            @RequestParam(value = "page", required = false, defaultValue = "1") int page); }
CommentController { @DeleteMapping("/user/comment/del") public Response delete(@RequestParam("id") long id) { return ResponseUtil.success(commentService.delete(id)); }  @PostMapping("/user/comment/create") Response addOne(@RequestBody CommentReq reqBody); @DeleteMapping("/user/comment/del") Response delete(@RequestParam("id") long id); @PutMapping("/user/comment/update") Response update(@RequestBody CommentReq reqBody); @GetMapping("/comments") Response commentsOfArticle(@RequestParam("articleId") long articleId,
                                      @RequestParam(value = "count", required = false, defaultValue = "10") int count,
                                      @RequestParam(value = "page", required = false, defaultValue = "1") int page); @GetMapping("/comment/pid/{pid}") Response retrievePage(@PathVariable("pid") long pid,
                                 @RequestParam(value = "count", required = false, defaultValue = "10") int count,
                                 @RequestParam(value = "page", required = false, defaultValue = "1") int page); @GetMapping("/leaveMsg") Response retrievePageOfLeaveMsg(@RequestParam(value = "count", required = false, defaultValue = "10") int count,
                                           @RequestParam(value = "page", required = false, defaultValue = "1") int page); @GetMapping("/admin/comment/type/{type}") Response retrievePageAdmin(
            @PathVariable("type") int isComment,
            @RequestParam(value = "count", required = false, defaultValue = "10") int count,
            @RequestParam(value = "page", required = false, defaultValue = "1") int page); @GetMapping("/user/comment/type/{type}") Response retrievePageByAuthor(
            @PathVariable(value = "type") int isComment,
            @RequestParam(value = "count", required = false, defaultValue = "10") int count,
            @RequestParam(value = "page", required = false, defaultValue = "1") int page);  }