测试用例zip下载修改
This commit is contained in:
parent
70552a714a
commit
952fc2988d
@ -3,6 +3,7 @@ package cd.casic.ci.api;
|
||||
|
||||
import cd.casic.ci.process.dto.req.testCase.TestCaseManagerQueryReq;
|
||||
import cd.casic.ci.process.dto.req.testCase.TestCaseManagerReq;
|
||||
import cd.casic.ci.process.dto.resp.testCase.TestCaseManagerDownloadResp;
|
||||
import cd.casic.ci.process.dto.resp.testCase.TestCaseManagerResp;
|
||||
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
||||
import cd.casic.ci.process.process.service.testCase.TestCaseManagerService;
|
||||
@ -85,7 +86,7 @@ public class TestCaseManagerController {
|
||||
return CommonResult.success(resp);
|
||||
}
|
||||
@GetMapping("/downLoadById")
|
||||
public void downLoadByManagerId(@RequestParam String managerId, HttpServletResponse response){
|
||||
testCaseManagerService.downLoadById(managerId,response);
|
||||
public CommonResult<TestCaseManagerDownloadResp> downLoadByManagerId(@RequestParam String managerId){
|
||||
return CommonResult.success(testCaseManagerService.downLoadById(managerId));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
package cd.casic.ci.process.dto.resp.testCase;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestCaseManagerDownloadResp {
|
||||
private String fileName;
|
||||
private String file;
|
||||
}
|
@ -29,6 +29,7 @@ public interface TargetVersionConverter {
|
||||
void updateReqCopyToTargetVersion(TargetVersionUpdateReq req,@MappingTarget TargetVersion targetVersion);
|
||||
|
||||
TargetVersion targetCreateReqToTargetVersionBean(TargetManagerCreateReq req);
|
||||
TargetVersionCreateReq targetCreateReqToTargetVersionCreateReq(TargetManagerCreateReq req);
|
||||
|
||||
TargetVersion versionCreateReqToTargetVersionBean(TargetVersionCreateReq req);
|
||||
}
|
||||
|
@ -46,4 +46,8 @@ public class TargetVersion extends PipBaseElement {
|
||||
* 文件地址路径
|
||||
*/
|
||||
private String filePath;
|
||||
/**
|
||||
* 目标版本
|
||||
* */
|
||||
private String versionCompose;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@ -77,11 +78,12 @@ public class TargetManagerServiceImpl extends ServiceImpl<TargetManagerDao, Targ
|
||||
}
|
||||
|
||||
this.save(targetManager);
|
||||
TargetVersionCreateReq targetVersion = TargetVersionConverter.INSTANCE.targetCreateReqToTargetVersionCreateReq(req);
|
||||
createVersion(targetVersion);
|
||||
// //保存第一个版本
|
||||
|
||||
//保存第一个版本
|
||||
TargetVersion targetVersion = TargetVersionConverter.INSTANCE.targetCreateReqToTargetVersionBean(req);
|
||||
targetVersion.setTargetId(targetManager.getId());
|
||||
targetVersionService.save(targetVersion);
|
||||
// targetVersion.setTargetId(targetManager.getId());
|
||||
// targetVersionService.save(targetVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -231,7 +233,7 @@ public class TargetManagerServiceImpl extends ServiceImpl<TargetManagerDao, Targ
|
||||
QueryWrapper<TargetVersion> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("version",targetVersion.getVersion());
|
||||
wrapper.eq("target_id",targetVersion.getTargetId());
|
||||
if (!ObjectUtils.isEmpty(targetVersionDao.selectList(wrapper))){
|
||||
if (!CollectionUtils.isEmpty(targetVersionDao.selectList(wrapper))){
|
||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"版本已存在");
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package cd.casic.ci.process.process.service.testCase;
|
||||
|
||||
import cd.casic.ci.process.dto.req.testCase.TestCaseManagerQueryReq;
|
||||
import cd.casic.ci.process.dto.req.testCase.TestCaseManagerReq;
|
||||
import cd.casic.ci.process.dto.resp.testCase.TestCaseManagerDownloadResp;
|
||||
import cd.casic.ci.process.dto.resp.testCase.TestCaseManagerResp;
|
||||
import cd.casic.ci.process.process.dataObject.testCase.TestCaseManager;
|
||||
import cd.casic.framework.commons.pojo.PageResult;
|
||||
@ -36,6 +37,6 @@ public interface TestCaseManagerService extends IService<TestCaseManager> {
|
||||
|
||||
TestCaseManagerResp findById(String id);
|
||||
|
||||
void downLoadById(String id , HttpServletResponse response);
|
||||
TestCaseManagerDownloadResp downLoadById(String id );
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ package cd.casic.ci.process.process.service.testCase.impl;
|
||||
import cd.casic.ci.process.dto.req.testCase.TestCaseManagerQueryReq;
|
||||
import cd.casic.ci.process.dto.req.testCase.TestCaseManagerReq;
|
||||
import cd.casic.ci.process.dto.resp.testCase.TestCaseInfoResp;
|
||||
import cd.casic.ci.process.dto.resp.testCase.TestCaseManagerDownloadResp;
|
||||
import cd.casic.ci.process.dto.resp.testCase.TestCaseManagerResp;
|
||||
import cd.casic.ci.process.process.converter.TestCaseManagerConverter;
|
||||
import cd.casic.ci.process.process.dao.testCase.TestCaseInfoDao;
|
||||
@ -25,7 +26,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jcraft.jsch.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@ -35,7 +35,6 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -152,11 +151,9 @@ public class TestCaseManagerServiceImpl extends ServiceImpl<TestCaseManagerDao,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downLoadById(String id, HttpServletResponse response) {
|
||||
response.setContentType("application/zip");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=SEED.zip");
|
||||
try (ServletOutputStream outputStream = response.getOutputStream();
|
||||
ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream)){
|
||||
public TestCaseManagerDownloadResp downLoadById(String id) {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
try (ZipOutputStream zipOutputStream = new ZipOutputStream(bos)){
|
||||
JSch jsch = new JSch();
|
||||
Session session = jsch.getSession(properties.getUsername(), properties.getRemoteHost(), properties.getRemotePort());
|
||||
session.setPassword(properties.getPassword());
|
||||
@ -183,6 +180,12 @@ public class TestCaseManagerServiceImpl extends ServiceImpl<TestCaseManagerDao,
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
byte[] byteArray = bos.toByteArray();
|
||||
String file = Base64.getEncoder().encodeToString(byteArray);
|
||||
TestCaseManagerDownloadResp testCaseManagerDownloadResp = new TestCaseManagerDownloadResp();
|
||||
testCaseManagerDownloadResp.setFile(file);
|
||||
testCaseManagerDownloadResp.setFileName("SEED.zip");
|
||||
return testCaseManagerDownloadResp;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user