@Test public void update() throws Exception { Comment comment = commentMapper.getLastestComment(); CommentReq commentReq = new CommentReq(); commentReq.setId(comment.getId()); commentReq.setPid(comment.getPid()); commentReq.setContent(UUID.randomUUID().toString()); commentReq.setArticleID(comment.getArticleID()); commentReq.setResponseId("xxxx"); commentReq.setComment(comment.getType()); mockMvc.perform(put("/user/comment/update") .content(JSONObject.fromObject(commentReq).toString()) .contentType(MediaType.APPLICATION_JSON_UTF8) .header("Authorization", userLogin()) ).andDo(result -> { JSONObject object = JSONObject.fromObject(result.getResponse().getContentAsString()); assertEquals(SUCCESS.getCode(), object.getInt(Code)); CommentModel c = (CommentModel) JSONObject.toBean(object.getJSONObject(Result), CommentModel.class); assertEquals(commentReq.getContent(), c.getContent()); assertEquals(commentReq.getResponseId(), c.getResponseId()); assertNotNull(c.getAuthorAvatarImgUrl()); assertNotNull(c.getAuthorName()); assertNotNull(c.getDate()); assertNotEquals(0, c.getPid()); assertNotEquals(0, c.getArticleID()); }); }
@PutMapping("/user/comment/update") public Response update(@RequestBody CommentReq reqBody) { return ResponseUtil.success(commentService.update(reqBody)); }
CommentController { @PutMapping("/user/comment/update") public Response update(@RequestBody CommentReq reqBody) { return ResponseUtil.success(commentService.update(reqBody)); } }
CommentController { @PutMapping("/user/comment/update") public Response update(@RequestBody CommentReq reqBody) { return ResponseUtil.success(commentService.update(reqBody)); }  }
CommentController { @PutMapping("/user/comment/update") public Response update(@RequestBody CommentReq reqBody) { return ResponseUtil.success(commentService.update(reqBody)); }  @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 { @PutMapping("/user/comment/update") public Response update(@RequestBody CommentReq reqBody) { return ResponseUtil.success(commentService.update(reqBody)); }  @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);  }