@Test public void commentsOfArticle() throws Exception { mockMvc.perform(get("/comments?articleId=3&page=1&count=10")).andDo(result -> { JSONObject object = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), object.getInt(Code)); PageInfo pageInfo = (PageInfo) JSONObject.toBean(object.getJSONObject(Result), PageInfo.class); assertNotEquals(0, pageInfo.getStartRow()); assertNotEquals(0, pageInfo.getEndRow()); assertEquals(1, pageInfo.getPageNum()); assertEquals(10, pageInfo.getPageSize()); pageInfo.getList().forEach(o -> { CommentModel model = (CommentModel) JSONObject.toBean(JSONObject.fromObject(o), CommentModel.class); assertEquals(3, model.getArticleID()); assertNotNull(model.getDate()); assertNotNull(model.getAuthorName()); assertNotNull(model.getAuthorAvatarImgUrl()); assertNotNull(model.getArticleTitle()); assertNotNull(model.getContent()); assertNotNull(model.getResponseId()); }); }); }
@GetMapping("/comments") public Response commentsOfArticle(@RequestParam("articleId") long articleId, @RequestParam(value = "count", required = false, defaultValue = "10") int count, @RequestParam(value = "page", required = false, defaultValue = "1") int page) { return ResponseUtil.success(commentService.retrievePageByArticle(articleId, -1, page, count)); }
CommentController { @GetMapping("/comments") public Response commentsOfArticle(@RequestParam("articleId") long articleId, @RequestParam(value = "count", required = false, defaultValue = "10") int count, @RequestParam(value = "page", required = false, defaultValue = "1") int page) { return ResponseUtil.success(commentService.retrievePageByArticle(articleId, -1, page, count)); } }
CommentController { @GetMapping("/comments") public Response commentsOfArticle(@RequestParam("articleId") long articleId, @RequestParam(value = "count", required = false, defaultValue = "10") int count, @RequestParam(value = "page", required = false, defaultValue = "1") int page) { return ResponseUtil.success(commentService.retrievePageByArticle(articleId, -1, page, count)); }  }
CommentController { @GetMapping("/comments") public Response commentsOfArticle(@RequestParam("articleId") long articleId, @RequestParam(value = "count", required = false, defaultValue = "10") int count, @RequestParam(value = "page", required = false, defaultValue = "1") int page) { return ResponseUtil.success(commentService.retrievePageByArticle(articleId, -1, page, count)); }  @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 { @GetMapping("/comments") public Response commentsOfArticle(@RequestParam("articleId") long articleId, @RequestParam(value = "count", required = false, defaultValue = "10") int count, @RequestParam(value = "page", required = false, defaultValue = "1") int page) { return ResponseUtil.success(commentService.retrievePageByArticle(articleId, -1, page, count)); }  @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);  }