|
|
@@ -1,18 +1,25 @@
|
|
|
package cn.seecoder.web.controller.codereview;
|
|
|
|
|
|
import cn.seecoder.common.exceptions.ServiceException;
|
|
|
+import cn.seecoder.web.model.enums.FileReviewStatusEnum;
|
|
|
import cn.seecoder.web.model.vo.Response;
|
|
|
import cn.seecoder.web.model.vo.codereview.CodeReviewCreateVO;
|
|
|
import cn.seecoder.web.model.vo.codereview.CodeReviewSortedList;
|
|
|
import cn.seecoder.web.model.vo.codereview.CodeReviewVO;
|
|
|
+import cn.seecoder.web.model.vo.codereview.FileNodeVO;
|
|
|
import cn.seecoder.web.model.vo.codereview.FileReviewCreateVO;
|
|
|
+import cn.seecoder.web.model.vo.codereview.FileReviewVO;
|
|
|
+import cn.seecoder.web.model.vo.user.UserVO;
|
|
|
import cn.seecoder.web.service.codereview.BranchReviewService;
|
|
|
import cn.seecoder.web.service.codereview.FileReviewService;
|
|
|
+import com.nju.edu.gitlab.vo.BranchVO;
|
|
|
+import com.nju.edu.gitlab.vo.DiffVO;
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* @author Zihe Chen
|
|
|
@@ -42,7 +49,7 @@ public class CodeReviewController {
|
|
|
@PostMapping("/branch_review")
|
|
|
@ApiOperation(value = "创建一个code_review", httpMethod = "POST")
|
|
|
@ApiImplicitParam(value = "codeReviewCreateVO", dataType = "object", paramType = "body")
|
|
|
- public Response createBranchReview(@RequestBody CodeReviewCreateVO codeReviewCreateVO) throws ServiceException {
|
|
|
+ public Response<Object> createBranchReview(@RequestBody CodeReviewCreateVO codeReviewCreateVO) throws ServiceException {
|
|
|
branchReviewService.create(codeReviewCreateVO);
|
|
|
return Response.buildSuccess();
|
|
|
}
|
|
|
@@ -57,7 +64,7 @@ public class CodeReviewController {
|
|
|
@PutMapping("/close/{codeReviewId}")
|
|
|
@ApiOperation(value = "关闭某个code_review", httpMethod = "PUT")
|
|
|
@ApiImplicitParam(value = "codeReviewId", dataType = "int", paramType = "query")
|
|
|
- public Response close(@PathVariable Integer codeReviewId){
|
|
|
+ public Response<Object> close(@PathVariable Integer codeReviewId){
|
|
|
branchReviewService.close(codeReviewId);
|
|
|
return Response.buildSuccess();
|
|
|
}
|
|
|
@@ -65,7 +72,7 @@ public class CodeReviewController {
|
|
|
@PutMapping("/reopen/{codeReviewId}")
|
|
|
@ApiOperation(value = "重开某个code_review", httpMethod = "PUT")
|
|
|
@ApiImplicitParam(value = "codeReviewId", dataType = "int", paramType = "query")
|
|
|
- public Response reopen(@PathVariable Integer codeReviewId){
|
|
|
+ public Response<Object> reopen(@PathVariable Integer codeReviewId){
|
|
|
branchReviewService.reopen(codeReviewId);
|
|
|
return Response.buildSuccess();
|
|
|
}
|
|
|
@@ -73,7 +80,7 @@ public class CodeReviewController {
|
|
|
@PutMapping("/merge/{codeReviewId}")
|
|
|
@ApiOperation(value = "合并某个code_review", httpMethod = "PUT")
|
|
|
@ApiImplicitParam(value = "codeReviewId", dataType = "int", paramType = "query")
|
|
|
- public Response merge(@PathVariable Integer codeReviewId) throws ServiceException {
|
|
|
+ public Response<Object> merge(@PathVariable Integer codeReviewId) throws ServiceException {
|
|
|
branchReviewService.merge(codeReviewId);
|
|
|
return Response.buildSuccess();
|
|
|
}
|
|
|
@@ -81,7 +88,7 @@ public class CodeReviewController {
|
|
|
@ApiOperation(value = "获取指定项目的所有branch信息", httpMethod = "GET")
|
|
|
@GetMapping("/branches/{projectId}")
|
|
|
@ApiImplicitParam(name = "projectId", dataType = "int", paramType = "query")
|
|
|
- public Response getProjectBranches(@PathVariable Integer projectId) throws ServiceException {
|
|
|
+ public Response<List<BranchVO>> getProjectBranches(@PathVariable Integer projectId) throws ServiceException {
|
|
|
return Response.buildSuccess(branchReviewService.getBranches(projectId));
|
|
|
}
|
|
|
|
|
|
@@ -92,7 +99,7 @@ public class CodeReviewController {
|
|
|
@ApiImplicitParam(name = "fromBash", dataType = "String", paramType = "query"),
|
|
|
@ApiImplicitParam(name = "toBash", dataType = "String", paramType = "query")
|
|
|
})
|
|
|
- public Response compare(@RequestParam("projectId")Integer projectId, @RequestParam("fromBash")String fromBash,
|
|
|
+ public Response<Set<DiffVO>> compare(@RequestParam("projectId")Integer projectId, @RequestParam("fromBash")String fromBash,
|
|
|
@RequestParam("toBash") String toBash) throws ServiceException {
|
|
|
return Response.buildSuccess(branchReviewService.compareBranches(projectId, fromBash, toBash));
|
|
|
}
|
|
|
@@ -100,7 +107,7 @@ public class CodeReviewController {
|
|
|
@PostMapping("/file_review")
|
|
|
@ApiOperation(value = "创建一个文件评审任务", httpMethod = "POST")
|
|
|
@ApiImplicitParam(value = "fileReviewCreateVO", dataType = "object", paramType = "body")
|
|
|
- public Response createFileReview(@RequestBody FileReviewCreateVO fileReviewCreateVO){
|
|
|
+ public Response<Object> createFileReview(@RequestBody FileReviewCreateVO fileReviewCreateVO){
|
|
|
fileReviewService.create(fileReviewCreateVO);
|
|
|
return Response.buildSuccess();
|
|
|
}
|
|
|
@@ -111,7 +118,7 @@ public class CodeReviewController {
|
|
|
@ApiImplicitParam(value = "fileReviewId", dataType = "int", paramType = "query"),
|
|
|
@ApiImplicitParam(value = "fileList", dataType = "array", paramType = "query")
|
|
|
})
|
|
|
- public Response updateFileList(@RequestParam("fileReviewId") int fileReviewId, @RequestParam("fileList") List<String> fileList){
|
|
|
+ public Response<Object> updateFileList(@RequestParam("fileReviewId") int fileReviewId, @RequestParam("fileList") List<String> fileList){
|
|
|
fileReviewService.updateFileList(fileReviewId, fileList);
|
|
|
return Response.buildSuccess();
|
|
|
}
|
|
|
@@ -119,13 +126,13 @@ public class CodeReviewController {
|
|
|
@GetMapping("/file_review/{fileReviewId}")
|
|
|
@ApiOperation(value = "获取一个文件评审任务详细信息", httpMethod = "GET")
|
|
|
@ApiImplicitParam(value = "fileReviewId", dataType = "int", paramType = "query")
|
|
|
- public Response getByFileReviewId(@PathVariable int fileReviewId){
|
|
|
+ public Response<FileReviewVO> getByFileReviewId(@PathVariable int fileReviewId){
|
|
|
return Response.buildSuccess(fileReviewService.getById(fileReviewId));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/repository_tree")
|
|
|
@ApiOperation(value = "获取仓库文件列表", httpMethod = "GET")
|
|
|
- public Response getRepositoryTree(@RequestParam("projectId") int projectId, @RequestParam("branch") String branch,
|
|
|
+ public Response<List<FileNodeVO>> getRepositoryTree(@RequestParam("projectId") int projectId, @RequestParam("branch") String branch,
|
|
|
@RequestParam(value = "path", required = false) String path) throws ServiceException {
|
|
|
if(path != null) return Response.buildSuccess(fileReviewService.getRepositoryTree(projectId, branch, path));
|
|
|
return Response.buildSuccess(fileReviewService.getRepositoryTree(projectId, branch));
|
|
|
@@ -133,39 +140,39 @@ public class CodeReviewController {
|
|
|
|
|
|
@GetMapping("/invite")
|
|
|
@ApiOperation(value = "通过手机号码邀请评审人", httpMethod = "GET")
|
|
|
- public Response inviteReviewer(@RequestParam("phoneNumber") String phoneNumber) throws ServiceException {
|
|
|
+ public Response<UserVO> inviteReviewer(@RequestParam("phoneNumber") String phoneNumber) throws ServiceException {
|
|
|
return Response.buildSuccess(fileReviewService.inviteUser(phoneNumber));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/file_content")
|
|
|
@ApiOperation(value = "获取某个文件的内容", httpMethod = "GET")
|
|
|
- public Response getFileContent(@RequestParam("projectId") int projectId, @RequestParam("branch") String branch,
|
|
|
+ public Response<String> getFileContent(@RequestParam("projectId") int projectId, @RequestParam("branch") String branch,
|
|
|
@RequestParam("path") String path) throws ServiceException {
|
|
|
return Response.buildSuccess(fileReviewService.getFile(projectId, branch, path));
|
|
|
}
|
|
|
|
|
|
@PutMapping("/inspect")
|
|
|
@ApiOperation(value = "将某个任务递交评审", httpMethod = "PUT")
|
|
|
- public Response submitToInspect(@RequestParam("fileReviewId") int fileReviewId) {
|
|
|
+ public Response<Object> submitToInspect(@RequestParam("fileReviewId") int fileReviewId) {
|
|
|
fileReviewService.submitToInspection(fileReviewId);
|
|
|
return Response.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@PutMapping("/rework")
|
|
|
@ApiOperation(value = "将某个任务要求返工修改", httpMethod = "PUT")
|
|
|
- public Response submitToRework(@RequestParam("fileReviewId") int fileReviewId, @RequestParam("reviewerId") int reviewerId) {
|
|
|
+ public Response<FileReviewStatusEnum> submitToRework(@RequestParam("fileReviewId") int fileReviewId, @RequestParam("reviewerId") int reviewerId) {
|
|
|
return Response.buildSuccess(fileReviewService.submitInspection(fileReviewId, reviewerId, 0));
|
|
|
}
|
|
|
|
|
|
@PutMapping("/complete")
|
|
|
@ApiOperation(value = "将某一任务结束", httpMethod = "PUT")
|
|
|
- public Response submitToComplete(@RequestParam("fileReviewId") int fileReviewId, @RequestParam("reviewerId") int reviewerId) {
|
|
|
+ public Response<FileReviewStatusEnum> submitToComplete(@RequestParam("fileReviewId") int fileReviewId, @RequestParam("reviewerId") int reviewerId) {
|
|
|
return Response.buildSuccess(fileReviewService.submitInspection(fileReviewId, reviewerId, 1));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/hasInspected")
|
|
|
@ApiOperation(value = "查看评审人员是否已提交结果", httpMethod = "GET")
|
|
|
- public Response hasInspected(@RequestParam("fileReviewId") int fileReviewId, @RequestParam("reviewerId") int reviewerId) {
|
|
|
+ public Response<Boolean> hasInspected(@RequestParam("fileReviewId") int fileReviewId, @RequestParam("reviewerId") int reviewerId) {
|
|
|
return Response.buildSuccess(fileReviewService.hasInspected(fileReviewId, reviewerId));
|
|
|
}
|
|
|
}
|