提交 92f57363 authored 作者: 马晨俊's avatar 马晨俊

mcj:更新git上传接口

上级 245fec19
...@@ -125,7 +125,7 @@ public class InspectController { ...@@ -125,7 +125,7 @@ public class InspectController {
@PostMapping("/git") @PostMapping("/git")
@ApiOperation("git下载代码进行评估") @ApiOperation("git下载代码进行评估")
public ResponseEntity inspect1(@RequestBody InspectParameter inspectParameter) { public ResponseEntity inspect1(@RequestBody InspectParameter inspectParameter) {
String path = GitLabUtil.downLoadProject(inspectParameter.getGitAddress(), inspectParameter.getGitName()); String path = GitLabUtil.downLoadProject(inspectParameter.getGitAddress());
inspectParameter.setId(UUIDUtil.getUUID()); inspectParameter.setId(UUIDUtil.getUUID());
inspectParameter.setSourceAddress(path); inspectParameter.setSourceAddress(path);
ReportVo reportVo = new ReportVo(); ReportVo reportVo = new ReportVo();
...@@ -378,7 +378,11 @@ public class InspectController { ...@@ -378,7 +378,11 @@ public class InspectController {
} }
@PostMapping("/uploads") @PostMapping("/uploads")
private ResponseEntity uploads(@RequestParam(value = "file") MultipartFile multfile){ private ResponseEntity uploads(@RequestParam(value = "file") MultipartFile multfile,String gitAddress){
if(gitAddress!=null){
String gitPath = GitLabUtil.downLoadProject(gitAddress);
return ResponseEntity.ok(gitPath);
}
try { try {
File file = FileUtil.saveToLocal(multfile); File file = FileUtil.saveToLocal(multfile);
String name = file.getName(); String name = file.getName();
......
...@@ -16,13 +16,13 @@ import java.time.LocalDate; ...@@ -16,13 +16,13 @@ import java.time.LocalDate;
@Component @Component
public class GitLabUtil { public class GitLabUtil {
public static String downLoadProject(String path,String name) { public static String downLoadProject(String path) {
String name1 = LocalDate.now().toString(); String name1 = LocalDate.now().toString();
String[] split1 = UUIDUtil.getUUID().split("-"); String[] split1 = UUIDUtil.getUUID().split("-");
//String REMOTE_URL = "https://git.yfzx.zjtys.com.cn:8888/912-system/monitor/adaptation-master.git"; //String REMOTE_URL = "https://git.yfzx.zjtys.com.cn:8888/912-system/monitor/adaptation-master.git";
CloneCommand cloneCommand = Git.cloneRepository(); CloneCommand cloneCommand = Git.cloneRepository();
cloneCommand.setURI(path); cloneCommand.setURI(path);
File file = new File("./"+name1+"/"+split1[0]+"/"+name); File file = new File("./"+name1+"/"+split1[0]+"/");
file.mkdirs(); file.mkdirs();
cloneCommand.setDirectory(file); cloneCommand.setDirectory(file);
try { try {
...@@ -38,6 +38,11 @@ public class GitLabUtil { ...@@ -38,6 +38,11 @@ public class GitLabUtil {
return file.getAbsolutePath(); return file.getAbsolutePath();
} }
public static void main(String[] args) {
String hostsss = GitLabUtil.downLoadProject("https://git.yfzx.zjtys.com.cn/912-system/monitor/inspect.git");
System.out.println(hostsss);
}
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论