提交 cf3668b4 authored 作者: czq's avatar czq

Merge branch 'master' of git.yfzx.zjtys.com.cn:912-system/monitor/inspect into czq

...@@ -116,26 +116,6 @@ public class InspectController { ...@@ -116,26 +116,6 @@ public class InspectController {
return ResponseEntity.ok(inspect); return ResponseEntity.ok(inspect);
} }
/**
* git下载代码进行评估
*
* @param inspectParameter 封装
* @return
*/
@PostMapping("/git")
@ApiOperation("git下载代码进行评估")
public ResponseEntity inspect1(@RequestBody InspectParameter inspectParameter) {
String path = GitLabUtil.downLoadProject(inspectParameter.getGitAddress());
inspectParameter.setId(UUIDUtil.getUUID());
inspectParameter.setSourceAddress(path);
ReportVo reportVo = new ReportVo();
reportVo.setUploadType("git下载");
reportVo.setSourceAddress(path);
reportVo.setGitAddress(inspectParameter.getGitAddress());
ReportVo inspect = inspectService.inspect(reportVo, inspectParameter);
return ResponseEntity.ok(inspect);
}
@PostMapping("/frontend") @PostMapping("/frontend")
@ApiOperation("git下载代码进行评估") @ApiOperation("git下载代码进行评估")
public ResponseEntity inspect(MultipartFile file) throws IOException { public ResponseEntity inspect(MultipartFile file) throws IOException {
...@@ -379,7 +359,7 @@ public class InspectController { ...@@ -379,7 +359,7 @@ public class InspectController {
} }
@PostMapping("/uploads") @PostMapping("/uploads")
private ResponseEntity uploads(@RequestParam(value = "file") MultipartFile multfile){ private ResponseEntity uploads(@RequestParam(value = "file") MultipartFile multfile,String s){
try { try {
File file = FileUtil.saveToLocal(multfile); File file = FileUtil.saveToLocal(multfile);
String name = file.getName(); String name = file.getName();
...@@ -391,8 +371,8 @@ public class InspectController { ...@@ -391,8 +371,8 @@ public class InspectController {
} }
} }
@PostMapping("/gitdownload") @PostMapping("/gitdownload")
private ResponseEntity gitDownloads(String gitAddress){ private ResponseEntity gitDownloads(String gitAddress,String username,String password){
String gitPath = GitLabUtil.downLoadProject(gitAddress); String gitPath = GitLabUtil.downLoadProject(gitAddress,username,password);
return ResponseEntity.ok(gitPath); return ResponseEntity.ok(gitPath);
} }
} }
...@@ -3,6 +3,7 @@ package com.zjty.inspect.utils; ...@@ -3,6 +3,7 @@ package com.zjty.inspect.utils;
import org.eclipse.jgit.api.CloneCommand; import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.File; import java.io.File;
...@@ -16,7 +17,7 @@ import java.time.LocalDate; ...@@ -16,7 +17,7 @@ import java.time.LocalDate;
@Component @Component
public class GitLabUtil { public class GitLabUtil {
public static String downLoadProject(String path) { public static String downLoadProject(String path,String username,String password) {
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";
...@@ -25,7 +26,9 @@ public class GitLabUtil { ...@@ -25,7 +26,9 @@ public class GitLabUtil {
File file = new File("./"+name1+"/"+split1[0]+"/"); File file = new File("./"+name1+"/"+split1[0]+"/");
file.mkdirs(); file.mkdirs();
cloneCommand.setDirectory(file); cloneCommand.setDirectory(file);
cloneCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username,password));
try { try {
cloneCommand.call(); cloneCommand.call();
} catch (GitAPIException e) { } catch (GitAPIException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -38,11 +41,6 @@ public class GitLabUtil { ...@@ -38,11 +41,6 @@ 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论