提交 21b6711e authored 作者: 马晨俊's avatar 马晨俊

mcj:更新git上传接口

上级 ce64c408
......@@ -378,7 +378,7 @@ public class InspectController {
}
@PostMapping("/uploads")
private ResponseEntity uploads(@RequestParam(value = "file") MultipartFile multfile){
private ResponseEntity uploads(@RequestParam(value = "file") MultipartFile multfile,String s){
try {
File file = FileUtil.saveToLocal(multfile);
String name = file.getName();
......@@ -390,7 +390,7 @@ public class InspectController {
}
}
@PostMapping("/gitdownload")
private ResponseEntity gitDownloads(String gitAddress){
private ResponseEntity gitDownloads(String gitAddress,String username,String password){
String gitPath = GitLabUtil.downLoadProject(gitAddress);
return ResponseEntity.ok(gitPath);
}
......
......@@ -3,6 +3,7 @@ package com.zjty.inspect.utils;
import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import org.springframework.stereotype.Component;
import java.io.File;
......@@ -16,7 +17,7 @@ import java.time.LocalDate;
@Component
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[] split1 = UUIDUtil.getUUID().split("-");
//String REMOTE_URL = "https://git.yfzx.zjtys.com.cn:8888/912-system/monitor/adaptation-master.git";
......@@ -25,7 +26,9 @@ public class GitLabUtil {
File file = new File("./"+name1+"/"+split1[0]+"/");
file.mkdirs();
cloneCommand.setDirectory(file);
cloneCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username,password));
try {
cloneCommand.call();
} catch (GitAPIException e) {
e.printStackTrace();
......@@ -38,11 +41,6 @@ public class GitLabUtil {
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论