@Test public void delete() { long articleId = articleMapper.getLastestArticleId(); try { mockMvc.perform(MockMvcRequestBuilders.delete("/admin/article/del?articleID=" + articleId) ).andDo(result -> { assertEquals(HAVE_NOT_LOG_IN.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code) ); }); String token = userLogin(); mockMvc.perform(MockMvcRequestBuilders.delete("/admin/article/del?articleID=" + articleId) .header("Authorization", token)) .andDo(result -> assertEquals(PERMISSION_ERROR.getCode(), JSONObject.fromObject(result.getResponse().getContentAsString()).getInt(Code)) ); token = adminLogin(); mockMvc.perform(MockMvcRequestBuilders.delete("/admin/article/del?articleID=" + articleId) .header("Authorization", token)) .andDo(result -> { JSONObject object = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), object.getInt(Code)); assertTrue(object.getBoolean(Result)); }); } catch (Exception e) { e.printStackTrace(); } }
@DeleteMapping("/admin/article/del") public Response delete(@RequestParam("articleID") long articleId) { boolean delete = articleService.delete(articleId); sitemapGenerateUtil.createSitemap(); return ResponseUtil.success(delete); }
ArticleController { @DeleteMapping("/admin/article/del") public Response delete(@RequestParam("articleID") long articleId) { boolean delete = articleService.delete(articleId); sitemapGenerateUtil.createSitemap(); return ResponseUtil.success(delete); } }
ArticleController { @DeleteMapping("/admin/article/del") public Response delete(@RequestParam("articleID") long articleId) { boolean delete = articleService.delete(articleId); sitemapGenerateUtil.createSitemap(); return ResponseUtil.success(delete); }  }
ArticleController { @DeleteMapping("/admin/article/del") public Response delete(@RequestParam("articleID") long articleId) { boolean delete = articleService.delete(articleId); sitemapGenerateUtil.createSitemap(); return ResponseUtil.success(delete); }  @PostMapping("/admin/article/create") Response create(@RequestBody ArticleReq body); @DeleteMapping("/admin/article/del") Response delete(@RequestParam("articleID") long articleId); @PutMapping("/admin/article/update") Response update(@RequestBody ArticleReq body); @GetMapping("/article/articleID/{articleID}") Response retrieveOneById(@PathVariable("articleID") long articleId,
                                    @RequestParam(value = "update", defaultValue = "false") boolean is4update,
                                    HttpServletRequest request); @GetMapping("/articles") Response articles(@RequestParam(name = "page", defaultValue = "1") int page,
                             @RequestParam(name = "count", defaultValue = "5") int count); @GetMapping("/admin/articles") Response adminArticles(@RequestParam(name = "page", defaultValue = "1") int page,
                                  @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/articles/category/{name}") Response findByCategory(@PathVariable("name") String name,
                                   @RequestParam(name = "page", defaultValue = "1") int page,
                                   @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/articles/tag/{name}") Response findByTag(@PathVariable("name") String name,
                              @RequestParam(name = "page", defaultValue = "1") int page,
                              @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/createSitemap") Response createSitemap(); }
ArticleController { @DeleteMapping("/admin/article/del") public Response delete(@RequestParam("articleID") long articleId) { boolean delete = articleService.delete(articleId); sitemapGenerateUtil.createSitemap(); return ResponseUtil.success(delete); }  @PostMapping("/admin/article/create") Response create(@RequestBody ArticleReq body); @DeleteMapping("/admin/article/del") Response delete(@RequestParam("articleID") long articleId); @PutMapping("/admin/article/update") Response update(@RequestBody ArticleReq body); @GetMapping("/article/articleID/{articleID}") Response retrieveOneById(@PathVariable("articleID") long articleId,
                                    @RequestParam(value = "update", defaultValue = "false") boolean is4update,
                                    HttpServletRequest request); @GetMapping("/articles") Response articles(@RequestParam(name = "page", defaultValue = "1") int page,
                             @RequestParam(name = "count", defaultValue = "5") int count); @GetMapping("/admin/articles") Response adminArticles(@RequestParam(name = "page", defaultValue = "1") int page,
                                  @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/articles/category/{name}") Response findByCategory(@PathVariable("name") String name,
                                   @RequestParam(name = "page", defaultValue = "1") int page,
                                   @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/articles/tag/{name}") Response findByTag(@PathVariable("name") String name,
                              @RequestParam(name = "page", defaultValue = "1") int page,
                              @RequestParam(name = "count", defaultValue = "10") int count); @GetMapping("/createSitemap") Response createSitemap();  }