| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package cn.seecoder.web.controller.codereview;
- import cn.seecoder.common.exceptions.ServiceException;
- import cn.seecoder.web.dto.Response;
- import cn.seecoder.web.dto.codereview.CommentCreateVO;
- import cn.seecoder.web.dto.codereview.CommentVO;
- import cn.seecoder.web.service.codereview.CommentService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.List;
- /**
- * @author Zihe Chen
- * @date 2022/1/12
- * @description:
- */
- @Api(tags = "Comment相关Api")
- @RestController
- @RequestMapping("/comment")
- public class CommentController {
- private final CommentService commentService;
- @Autowired
- public CommentController(CommentService commentService) {
- this.commentService = commentService;
- }
- @GetMapping("/{codeReviewId}")
- @ApiOperation(value = "获取一个CodeReview的所有评论", httpMethod = "GET")
- @ApiImplicitParam(value = "codeReviewId", dataType = "int", paramType = "query")
- public Response<List<CommentVO>> list(@PathVariable Integer codeReviewId) throws ServiceException {
- return Response.buildSuccess(commentService.list(codeReviewId, false));
- }
- @GetMapping("/listForFileReview/{fileReviewId}")
- @ApiOperation(value = "获取文件评审的所有评论", httpMethod = "GET")
- @ApiImplicitParam(value = "fileReview", dataType = "int", paramType = "query")
- public Response<List<CommentVO>> listForFileReview(@PathVariable Integer fileReviewId) throws ServiceException {
- return Response.buildSuccess(commentService.list(fileReviewId, true));
- }
- @PostMapping("/create")
- @ApiOperation(value = "创建一条新的Comment", httpMethod = "POST")
- @ApiImplicitParam(value = "commentCreateVO", dataType = "object", paramType = "body")
- public Response<Object> create(@RequestBody CommentCreateVO commentCreateVO) {
- commentService.create(commentCreateVO, false);
- return Response.buildSuccess();
- }
- @PostMapping("/createForFileReview")
- @ApiOperation(value = "为文件评审创建一条评论", httpMethod = "POST")
- @ApiImplicitParam(value = "commentCreateVO", dataType = "object", paramType = "body")
- public Response<Object> createForFileReview(@RequestBody CommentCreateVO commentCreateVO) {
- commentService.create(commentCreateVO, true);
- return Response.buildSuccess();
- }
- }
|