|
|
@@ -8,14 +8,10 @@ import cn.seecoder.web.model.vo.codereview.CodeReviewVO;
|
|
|
import cn.seecoder.web.model.vo.codereview.FileReviewCreateVO;
|
|
|
import cn.seecoder.web.service.codereview.BranchReviewService;
|
|
|
import cn.seecoder.web.service.codereview.FileReviewService;
|
|
|
-import com.nju.edu.gitlab.SeecoderGitlabApi;
|
|
|
-import com.nju.edu.gitlab.SeecoderGitlabException;
|
|
|
import io.swagger.annotations.*;
|
|
|
-import org.gitlab4j.api.GitLabApiException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -46,13 +42,9 @@ 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){
|
|
|
- try{
|
|
|
- branchReviewService.create(codeReviewCreateVO);
|
|
|
- return Response.buildSuccess();
|
|
|
- } catch (RuntimeException exception) {
|
|
|
- return Response.buildFailure(500, exception.getMessage());
|
|
|
- }
|
|
|
+ public Response createBranchReview(@RequestBody CodeReviewCreateVO codeReviewCreateVO) throws ServiceException {
|
|
|
+ branchReviewService.create(codeReviewCreateVO);
|
|
|
+ return Response.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@GetMapping("/branch_review/{codeReviewId}")
|
|
|
@@ -81,24 +73,16 @@ public class CodeReviewController {
|
|
|
@PutMapping("/merge/{codeReviewId}")
|
|
|
@ApiOperation(value = "合并某个code_review", httpMethod = "PUT")
|
|
|
@ApiImplicitParam(value = "codeReviewId", dataType = "int", paramType = "query")
|
|
|
- public Response merge(@PathVariable("codeReviewId") Integer codeReviewId) {
|
|
|
- try{
|
|
|
- branchReviewService.merge(codeReviewId);
|
|
|
- return Response.buildSuccess();
|
|
|
- } catch (SeecoderGitlabException | GitLabApiException exception) {
|
|
|
- return Response.buildFailure(500, exception.getMessage());
|
|
|
- }
|
|
|
+ public Response merge(@PathVariable("codeReviewId") Integer codeReviewId) throws ServiceException {
|
|
|
+ branchReviewService.merge(codeReviewId);
|
|
|
+ return Response.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取指定项目的所有branch信息", httpMethod = "GET")
|
|
|
@GetMapping("/branches/{projectId}")
|
|
|
@ApiImplicitParam(name = "projectId", dataType = "int", paramType = "query")
|
|
|
- public Response getProjectBranches(@PathVariable("projectId") Integer projectId){
|
|
|
- try{
|
|
|
- return Response.buildSuccess(branchReviewService.getBranches(projectId));
|
|
|
- } catch (SeecoderGitlabException exception) {
|
|
|
- return Response.buildFailure(500, exception.getMessage());
|
|
|
- }
|
|
|
+ public Response getProjectBranches(@PathVariable("projectId") Integer projectId) throws ServiceException {
|
|
|
+ return Response.buildSuccess(branchReviewService.getBranches(projectId));
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "获取两个分支的比较信息", httpMethod = "GET")
|
|
|
@@ -109,12 +93,8 @@ public class CodeReviewController {
|
|
|
@ApiImplicitParam(name = "toBash", dataType = "String", paramType = "query")
|
|
|
})
|
|
|
public Response compare(@RequestParam("projectId")Integer projectId, @RequestParam("fromBash")String fromBash,
|
|
|
- @RequestParam("toBash") String toBash){
|
|
|
- try{
|
|
|
- return Response.buildSuccess(branchReviewService.compareBranches(projectId, fromBash, toBash));
|
|
|
- } catch (SeecoderGitlabException exception) {
|
|
|
- return Response.buildFailure(500, exception.getMessage());
|
|
|
- }
|
|
|
+ @RequestParam("toBash") String toBash) throws ServiceException {
|
|
|
+ return Response.buildSuccess(branchReviewService.compareBranches(projectId, fromBash, toBash));
|
|
|
}
|
|
|
|
|
|
@PostMapping("/file_review")
|
|
|
@@ -146,34 +126,22 @@ public class CodeReviewController {
|
|
|
@GetMapping("/repository_tree")
|
|
|
@ApiOperation(value = "获取仓库文件列表", httpMethod = "GET")
|
|
|
public Response getRepositoryTree(@RequestParam("projectId") int projectId, @RequestParam("branch") String branch,
|
|
|
- @RequestParam(value = "path", required = false) String path) {
|
|
|
- try {
|
|
|
- if(path != null) return Response.buildSuccess(fileReviewService.getRepositoryTree(projectId, branch, path));
|
|
|
- else return Response.buildSuccess(fileReviewService.getRepositoryTree(projectId, branch));
|
|
|
- } catch (SeecoderGitlabException exception) {
|
|
|
- return Response.buildFailure(500, exception.getMessage());
|
|
|
- }
|
|
|
+ @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));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/invite")
|
|
|
@ApiOperation(value = "通过手机号码邀请评审人", httpMethod = "GET")
|
|
|
- public Response inviteReviewer(@RequestParam("phoneNumber") String phoneNumber) {
|
|
|
- try {
|
|
|
- return Response.buildSuccess(fileReviewService.inviteUser(phoneNumber));
|
|
|
- } catch (ServiceException exception) {
|
|
|
- return Response.buildFailure(exception.getCode(), exception.getMessage());
|
|
|
- }
|
|
|
+ public Response 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,
|
|
|
- @RequestParam("path") String path) {
|
|
|
- try{
|
|
|
- return Response.buildSuccess(fileReviewService.getFile(projectId, branch, path));
|
|
|
- } catch (SeecoderGitlabException exception) {
|
|
|
- return Response.buildFailure(500, exception.getMessage());
|
|
|
- }
|
|
|
+ @RequestParam("path") String path) throws ServiceException {
|
|
|
+ return Response.buildSuccess(fileReviewService.getFile(projectId, branch, path));
|
|
|
}
|
|
|
|
|
|
@PutMapping("/inspect")
|