Compare commits
No commits in common. "3685c0a312b653bba2a27cb3855ec53db3dbf62e" and "7160577a5688d1a3f6e730ad3dd2fae57c63c3a8" have entirely different histories.
3685c0a312
...
7160577a56
@ -53,7 +53,7 @@ public class TestCaseInfoController {
|
|||||||
@PostMapping(path="/update")
|
@PostMapping(path="/update")
|
||||||
public CommonResult<Void> update(@RequestBody @NotNull @Valid TestCaseInfoReq req){
|
public CommonResult<Void> update(@RequestBody @NotNull @Valid TestCaseInfoReq req){
|
||||||
|
|
||||||
testCaseInfoService.updateTestCaseInfo(req);
|
testCaseInfoService.updateTestCase(req);
|
||||||
|
|
||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
}
|
}
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
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.TestCaseManagerResp;
|
|
||||||
import cd.casic.ci.process.process.dataObject.base.BaseIdReq;
|
|
||||||
import cd.casic.ci.process.process.service.testCase.TestCaseManagerService;
|
|
||||||
import cd.casic.framework.commons.pojo.CommonResult;
|
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
|
||||||
import com.jcraft.jsch.JSchException;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName ResourceController
|
|
||||||
* @Author hopeli
|
|
||||||
* @Date 2025/5/10 10:57
|
|
||||||
* @Version 1.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/testCaseManager")
|
|
||||||
public class TestCaseManagerController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private TestCaseManagerService testCaseManagerService;
|
|
||||||
|
|
||||||
@PostMapping(path="/create")
|
|
||||||
public CommonResult<String> create(@RequestBody @Valid TestCaseManagerReq req){
|
|
||||||
|
|
||||||
String id = testCaseManagerService.create(req);
|
|
||||||
|
|
||||||
return CommonResult.success(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(path="/delete")
|
|
||||||
public CommonResult<Void> delete(@RequestBody @Valid BaseIdReq req) throws JSchException, InterruptedException {
|
|
||||||
|
|
||||||
testCaseManagerService.delete(req.getId());
|
|
||||||
|
|
||||||
return CommonResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(path="/update")
|
|
||||||
public CommonResult<Void> update(@RequestBody @NotNull @Valid TestCaseManagerReq req){
|
|
||||||
|
|
||||||
testCaseManagerService.updateTestCaseManager(req);
|
|
||||||
|
|
||||||
return CommonResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(path="/findList")
|
|
||||||
public CommonResult<List<TestCaseManagerResp>> findList(@RequestBody @Valid TestCaseManagerQueryReq query){
|
|
||||||
|
|
||||||
List<TestCaseManagerResp> respList = testCaseManagerService.findList(query);
|
|
||||||
|
|
||||||
return CommonResult.success(respList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(path="/findPage")
|
|
||||||
public CommonResult<PageResult<TestCaseManagerResp>> findResourcePage(@RequestBody @NotNull @Valid TestCaseManagerQueryReq query){
|
|
||||||
|
|
||||||
PageResult<TestCaseManagerResp> respPage = testCaseManagerService.findPage(query);
|
|
||||||
return CommonResult.success(respPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(path="/findById")
|
|
||||||
public CommonResult<TestCaseManagerResp> findById(@RequestBody @Valid BaseIdReq req){
|
|
||||||
|
|
||||||
TestCaseManagerResp resp = testCaseManagerService.findById(req.getId());
|
|
||||||
|
|
||||||
return CommonResult.success(resp);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -13,8 +13,6 @@ public class TestCaseInfoQueryReq extends PageParam {
|
|||||||
|
|
||||||
private List<String> idList;
|
private List<String> idList;
|
||||||
|
|
||||||
private String testCaseManagerId;
|
|
||||||
|
|
||||||
// 测试用例名称
|
// 测试用例名称
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ import lombok.Data;
|
|||||||
public class TestCaseInfoReq {
|
public class TestCaseInfoReq {
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private String testCaseManagerId;
|
|
||||||
|
|
||||||
// 测试用例名称
|
// 测试用例名称
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
package cd.casic.ci.process.dto.req.testCase;
|
|
||||||
|
|
||||||
import cd.casic.framework.commons.pojo.PageParam;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class TestCaseManagerQueryReq extends PageParam {
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
private List<String> idList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试用例管理名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试用例管理类型
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件夹路径,用于统一上传文件地址
|
|
||||||
*/
|
|
||||||
private String folderPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package cd.casic.ci.process.dto.req.testCase;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class TestCaseManagerReq {
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试用例管理名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试用例管理类型
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件夹路径,用于统一上传文件地址
|
|
||||||
*/
|
|
||||||
private String folderPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
}
|
|
@ -8,8 +8,6 @@ import java.time.LocalDateTime;
|
|||||||
public class TestCaseInfoResp {
|
public class TestCaseInfoResp {
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private String testCaseManagerId;
|
|
||||||
|
|
||||||
// 测试用例名称
|
// 测试用例名称
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
package cd.casic.ci.process.dto.resp.testCase;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class TestCaseManagerResp {
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试用例管理名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试用例管理类型
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件夹路径,用于统一上传文件地址
|
|
||||||
*/
|
|
||||||
private String folderPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
//创建人id
|
|
||||||
private String creator;
|
|
||||||
|
|
||||||
//创建人姓名
|
|
||||||
private String creatorName;
|
|
||||||
|
|
||||||
//最后修改人id
|
|
||||||
private String updater;
|
|
||||||
|
|
||||||
//最后修改人姓名
|
|
||||||
private String updaterName;
|
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
}
|
|
@ -4,8 +4,6 @@ import cd.casic.ci.process.dto.req.testCase.TestCaseInfoReq;
|
|||||||
import cd.casic.ci.process.dto.resp.testCase.TestCaseInfoResp;
|
import cd.casic.ci.process.dto.resp.testCase.TestCaseInfoResp;
|
||||||
import cd.casic.ci.process.process.dataObject.testCase.TestCaseInfo;
|
import cd.casic.ci.process.process.dataObject.testCase.TestCaseInfo;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.MappingTarget;
|
|
||||||
import org.mapstruct.NullValuePropertyMappingStrategy;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,7 +15,7 @@ import java.util.List;
|
|||||||
* @Date: 2025/5/13 14:39
|
* @Date: 2025/5/13 14:39
|
||||||
* @Description:
|
* @Description:
|
||||||
*/
|
*/
|
||||||
@Mapper(componentModel = "spring",nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
|
@Mapper(componentModel = "spring")
|
||||||
public interface TestCaseInfoConverter {
|
public interface TestCaseInfoConverter {
|
||||||
TestCaseInfoConverter INSTANCE = Mappers.getMapper(TestCaseInfoConverter.class);
|
TestCaseInfoConverter INSTANCE = Mappers.getMapper(TestCaseInfoConverter.class);
|
||||||
|
|
||||||
@ -26,6 +24,4 @@ public interface TestCaseInfoConverter {
|
|||||||
List<TestCaseInfoResp> toRespList(List<TestCaseInfo> testCaseInfos);
|
List<TestCaseInfoResp> toRespList(List<TestCaseInfo> testCaseInfos);
|
||||||
|
|
||||||
TestCaseInfoResp toResp(TestCaseInfo testCaseInfo);
|
TestCaseInfoResp toResp(TestCaseInfo testCaseInfo);
|
||||||
|
|
||||||
void updateReqCopyToBean(TestCaseInfoReq req, @MappingTarget TestCaseInfo testCaseInfo);
|
|
||||||
}
|
}
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package cd.casic.ci.process.process.converter;
|
|
||||||
|
|
||||||
import cd.casic.ci.process.dto.req.testCase.TestCaseManagerReq;
|
|
||||||
import cd.casic.ci.process.dto.resp.testCase.TestCaseManagerResp;
|
|
||||||
import cd.casic.ci.process.process.dataObject.testCase.TestCaseManager;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.MappingTarget;
|
|
||||||
import org.mapstruct.NullValuePropertyMappingStrategy;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author HopeLi
|
|
||||||
* @version v1.0
|
|
||||||
* @ClassName PipelineConverter
|
|
||||||
* @Date: 2025/5/13 14:39
|
|
||||||
* @Description:
|
|
||||||
*/
|
|
||||||
@Mapper(componentModel = "spring",nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
|
|
||||||
public interface TestCaseManagerConverter {
|
|
||||||
TestCaseManagerConverter INSTANCE = Mappers.getMapper(TestCaseManagerConverter.class);
|
|
||||||
|
|
||||||
TestCaseManager toBean(TestCaseManagerReq req);
|
|
||||||
|
|
||||||
void updateReqCopyToBean(TestCaseManagerReq req, @MappingTarget TestCaseManager testCaseManager);
|
|
||||||
|
|
||||||
List<TestCaseManagerResp> toRespList(List<TestCaseManager> testCaseManagers);
|
|
||||||
|
|
||||||
TestCaseManagerResp toResp(TestCaseManager testCaseManager);
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package cd.casic.ci.process.process.dao.testCase;
|
|
||||||
|
|
||||||
import cd.casic.ci.process.process.dataObject.testCase.TestCaseManager;
|
|
||||||
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author HopeLi
|
|
||||||
* @version v1.0
|
|
||||||
* @ClassName PipelineDao
|
|
||||||
* @Date: 2025/5/13 14:39
|
|
||||||
* @Description:
|
|
||||||
*/
|
|
||||||
public interface TestCaseManagerDao extends BaseMapperX<TestCaseManager>, BaseMapper<TestCaseManager> {
|
|
||||||
}
|
|
@ -17,8 +17,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
@TableName("test_case_info")
|
@TableName("test_case_info")
|
||||||
public class TestCaseInfo extends PipBaseElement {
|
public class TestCaseInfo extends PipBaseElement {
|
||||||
|
|
||||||
private String testCaseManagerId;
|
|
||||||
|
|
||||||
// 测试用例名称
|
// 测试用例名称
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
package cd.casic.ci.process.process.dataObject.testCase;
|
|
||||||
|
|
||||||
import cd.casic.ci.process.process.dataObject.base.PipBaseElement;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author HopeLi
|
|
||||||
* @version v1.0
|
|
||||||
* @ClassName TestCaseInfo
|
|
||||||
* @Date: 2025/6/24 16:40
|
|
||||||
* @Description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("test_case_info")
|
|
||||||
public class TestCaseManager extends PipBaseElement {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试用例管理名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试用例管理类型
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件夹路径,用于统一上传文件地址
|
|
||||||
*/
|
|
||||||
private String folderPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 描述
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
}
|
|
@ -24,7 +24,7 @@ public interface TestCaseInfoService extends IService<TestCaseInfo> {
|
|||||||
|
|
||||||
void delete(String id);
|
void delete(String id);
|
||||||
|
|
||||||
void updateTestCaseInfo(@Valid TestCaseInfoReq req);
|
void updateTestCase(@Valid TestCaseInfoReq req);
|
||||||
|
|
||||||
List<TestCaseInfoResp> findList(@Valid TestCaseInfoQueryReq query);
|
List<TestCaseInfoResp> findList(@Valid TestCaseInfoQueryReq query);
|
||||||
|
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
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.TestCaseManagerResp;
|
|
||||||
import cd.casic.ci.process.process.dataObject.testCase.TestCaseManager;
|
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.jcraft.jsch.JSchException;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author HopeLi
|
|
||||||
* @version v1.0
|
|
||||||
* @ClassName PipelineService
|
|
||||||
* @Date: 2025/5/13 10:27
|
|
||||||
* @Description:
|
|
||||||
*/
|
|
||||||
public interface TestCaseManagerService extends IService<TestCaseManager> {
|
|
||||||
|
|
||||||
String create(@Valid TestCaseManagerReq req);
|
|
||||||
|
|
||||||
void delete(String id) throws JSchException, InterruptedException;
|
|
||||||
|
|
||||||
void updateTestCaseManager(@Valid TestCaseManagerReq req);
|
|
||||||
|
|
||||||
List<TestCaseManagerResp> findList(@Valid TestCaseManagerQueryReq query);
|
|
||||||
|
|
||||||
PageResult<TestCaseManagerResp> findPage(@Valid TestCaseManagerQueryReq query);
|
|
||||||
|
|
||||||
TestCaseManagerResp findById(String id);
|
|
||||||
|
|
||||||
}
|
|
@ -52,36 +52,20 @@ public class TestCaseInfoServiceImpl extends ServiceImpl<TestCaseInfoDao, TestCa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String id) {
|
public void delete(String id) {
|
||||||
TestCaseInfo testCaseInfo = testCaseInfoDao.selectById(id);
|
|
||||||
if (ObjectUtils.isEmpty(testCaseInfo)){
|
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"数据错误请联系管理员");
|
|
||||||
}
|
|
||||||
testCaseInfoDao.deleteById(id);
|
testCaseInfoDao.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTestCaseInfo(TestCaseInfoReq req) {
|
public void updateTestCase(TestCaseInfoReq req) {
|
||||||
TestCaseInfo testCaseInfo = testCaseInfoDao.selectById(req.getId());
|
TestCaseInfo testCaseInfo = TestCaseInfoConverter.INSTANCE.toBean(req);
|
||||||
if (ObjectUtils.isEmpty(testCaseInfo)){
|
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"数据错误请联系管理员");
|
|
||||||
}
|
|
||||||
|
|
||||||
TestCaseInfoConverter.INSTANCE.updateReqCopyToBean(req,testCaseInfo);
|
|
||||||
testCaseInfoDao.updateById(testCaseInfo);
|
testCaseInfoDao.updateById(testCaseInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TestCaseInfoResp> findList(TestCaseInfoQueryReq query) {
|
public List<TestCaseInfoResp> findList(TestCaseInfoQueryReq query) {
|
||||||
QueryWrapper<TestCaseInfo> wrapper = new QueryWrapper<>();
|
QueryWrapper<TestCaseInfo> wrapper = new QueryWrapper<>();
|
||||||
if (!StringUtils.isEmpty(query.getTestFileType())){
|
|
||||||
wrapper.eq("test_file_type", query.getTestFileType());
|
|
||||||
}
|
|
||||||
if (!StringUtils.isEmpty(query.getTestCaseManagerId())){
|
|
||||||
wrapper.eq("test_case_manager_id", query.getTestCaseManagerId());
|
|
||||||
}
|
|
||||||
List<TestCaseInfo> testCaseInfos = testCaseInfoDao.selectList(wrapper);
|
List<TestCaseInfo> testCaseInfos = testCaseInfoDao.selectList(wrapper);
|
||||||
|
|
||||||
|
|
||||||
if (ObjectUtils.isEmpty(testCaseInfos)){
|
if (ObjectUtils.isEmpty(testCaseInfos)){
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
@ -98,9 +82,6 @@ public class TestCaseInfoServiceImpl extends ServiceImpl<TestCaseInfoDao, TestCa
|
|||||||
if (!StringUtils.isEmpty(query.getTestFileType())){
|
if (!StringUtils.isEmpty(query.getTestFileType())){
|
||||||
wrapper.eq("test_file_type", query.getTestFileType());
|
wrapper.eq("test_file_type", query.getTestFileType());
|
||||||
}
|
}
|
||||||
if (!StringUtils.isEmpty(query.getTestCaseManagerId())){
|
|
||||||
wrapper.eq("test_case_manager_id", query.getTestCaseManagerId());
|
|
||||||
}
|
|
||||||
Page<TestCaseInfo> testCaseInfoPage = testCaseInfoDao.selectPage(new Page<>(query.getPageNo(), query.getPageSize()), wrapper);
|
Page<TestCaseInfo> testCaseInfoPage = testCaseInfoDao.selectPage(new Page<>(query.getPageNo(), query.getPageSize()), wrapper);
|
||||||
if (ObjectUtils.isEmpty(testCaseInfoPage)){
|
if (ObjectUtils.isEmpty(testCaseInfoPage)){
|
||||||
return new PageResult<>();
|
return new PageResult<>();
|
||||||
|
@ -1,185 +0,0 @@
|
|||||||
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.TestCaseManagerResp;
|
|
||||||
import cd.casic.ci.process.process.converter.TestCaseManagerConverter;
|
|
||||||
import cd.casic.ci.process.process.dao.testCase.TestCaseManagerDao;
|
|
||||||
import cd.casic.ci.process.process.dataObject.testCase.TestCaseManager;
|
|
||||||
import cd.casic.ci.process.process.service.testCase.TestCaseManagerService;
|
|
||||||
import cd.casic.ci.process.properties.TargetFileUploadProperties;
|
|
||||||
import cd.casic.framework.commons.exception.ServiceException;
|
|
||||||
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
|
||||||
import cd.casic.framework.commons.pojo.PageResult;
|
|
||||||
import cd.casic.framework.security.dal.user.AdminUserDO;
|
|
||||||
import cd.casic.framework.tenant.core.service.AdminUserServiceImpl;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.jcraft.jsch.ChannelExec;
|
|
||||||
import com.jcraft.jsch.JSch;
|
|
||||||
import com.jcraft.jsch.JSchException;
|
|
||||||
import com.jcraft.jsch.Session;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
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.ObjectUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author HopeLi
|
|
||||||
* @version v1.0
|
|
||||||
* @ClassName PipelineServiceImpl
|
|
||||||
* @Date: 2025/5/13 10:31
|
|
||||||
* @Description:
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@Slf4j
|
|
||||||
public class TestCaseManagerServiceImpl extends ServiceImpl<TestCaseManagerDao, TestCaseManager> implements TestCaseManagerService {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private TestCaseManagerDao testCaseManagerDao;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AdminUserServiceImpl adminUserService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private TargetFileUploadProperties fileUploadProperties;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String create(TestCaseManagerReq req) {
|
|
||||||
TestCaseManager testCaseManager = TestCaseManagerConverter.INSTANCE.toBean(req);
|
|
||||||
testCaseManagerDao.insert(testCaseManager);
|
|
||||||
return testCaseManager.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void delete(String id) throws JSchException, InterruptedException {
|
|
||||||
TestCaseManager testCaseManager = testCaseManagerDao.selectById(id);
|
|
||||||
if (ObjectUtils.isEmpty(testCaseManager)){
|
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"数据错误请联系管理员");
|
|
||||||
}
|
|
||||||
testCaseManagerDao.deleteById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateTestCaseManager(TestCaseManagerReq req) {
|
|
||||||
TestCaseManager testCaseManager = testCaseManagerDao.selectById(req.getId());
|
|
||||||
if (ObjectUtils.isEmpty(testCaseManager)){
|
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"数据错误请联系管理员");
|
|
||||||
}
|
|
||||||
TestCaseManagerConverter.INSTANCE.updateReqCopyToBean(req,testCaseManager);
|
|
||||||
testCaseManagerDao.updateById(testCaseManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<TestCaseManagerResp> findList(TestCaseManagerQueryReq query) {
|
|
||||||
QueryWrapper<TestCaseManager> wrapper = new QueryWrapper<>();
|
|
||||||
List<TestCaseManager> testCaseManagers = testCaseManagerDao.selectList(wrapper);
|
|
||||||
|
|
||||||
if (ObjectUtils.isEmpty(testCaseManagers)){
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
List<TestCaseManagerResp> respList = TestCaseManagerConverter.INSTANCE.toRespList(testCaseManagers);
|
|
||||||
respList.forEach(this::setUserName);
|
|
||||||
return respList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<TestCaseManagerResp> findPage(TestCaseManagerQueryReq query) {
|
|
||||||
QueryWrapper<TestCaseManager> wrapper = new QueryWrapper<>();
|
|
||||||
if (!StringUtils.isEmpty(query.getName())){
|
|
||||||
wrapper.like("name", query.getName());
|
|
||||||
}
|
|
||||||
if (!StringUtils.isEmpty(query.getType())){
|
|
||||||
wrapper.eq("type", query.getType());
|
|
||||||
}
|
|
||||||
Page<TestCaseManager> testCaseManagerPage = testCaseManagerDao.selectPage(new Page<>(query.getPageNo(), query.getPageSize()), wrapper);
|
|
||||||
if (ObjectUtils.isEmpty(testCaseManagerPage)){
|
|
||||||
return new PageResult<>();
|
|
||||||
}
|
|
||||||
List<TestCaseManagerResp> respList = TestCaseManagerConverter.INSTANCE.toRespList(testCaseManagerPage.getRecords());
|
|
||||||
respList.forEach(this::setUserName);
|
|
||||||
return new PageResult<>(respList,testCaseManagerPage.getTotal(),testCaseManagerPage.getCurrent(),testCaseManagerPage.getSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TestCaseManagerResp findById(String id) {
|
|
||||||
TestCaseManager testCaseManager = testCaseManagerDao.selectById(id);
|
|
||||||
if (ObjectUtils.isEmpty(testCaseManager)){
|
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"数据错误请联系管理员");
|
|
||||||
}
|
|
||||||
TestCaseManagerResp testCaseManagerResp = TestCaseManagerConverter.INSTANCE.toResp(testCaseManager);
|
|
||||||
setUserName(testCaseManagerResp);
|
|
||||||
return testCaseManagerResp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void setUserName(TestCaseManagerResp testCaseManagerResp) {
|
|
||||||
if (!StringUtils.isEmpty(testCaseManagerResp.getCreator())){
|
|
||||||
AdminUserDO user = adminUserService.getUser(Long.valueOf(testCaseManagerResp.getCreator()));
|
|
||||||
if (!ObjectUtils.isEmpty(user)){
|
|
||||||
testCaseManagerResp.setCreatorName(user.getUsername());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(testCaseManagerResp.getUpdater())){
|
|
||||||
AdminUserDO user = adminUserService.getUser(Long.valueOf(testCaseManagerResp.getUpdater()));
|
|
||||||
if (!ObjectUtils.isEmpty(user)){
|
|
||||||
testCaseManagerResp.setUpdaterName(user.getUsername());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void deleteRemoteFolder(String folderPath) throws JSchException, InterruptedException {
|
|
||||||
JSch jsch = new JSch();
|
|
||||||
Session session = null;
|
|
||||||
ChannelExec channel = null;
|
|
||||||
String username = fileUploadProperties.getUsername();
|
|
||||||
String host = fileUploadProperties.getRemoteHost();
|
|
||||||
Integer port = 22;
|
|
||||||
String password = fileUploadProperties.getPassword();
|
|
||||||
|
|
||||||
try {
|
|
||||||
session = jsch.getSession(username, host, port);
|
|
||||||
session.setPassword(password);
|
|
||||||
|
|
||||||
// 设置首次登录不自动添加密钥
|
|
||||||
session.setConfig("StrictHostKeyChecking", "no");
|
|
||||||
session.connect();
|
|
||||||
|
|
||||||
// 构建删除命令(递归删除)
|
|
||||||
String command = String.format("rm -rf %s", folderPath);
|
|
||||||
|
|
||||||
channel = (ChannelExec) session.openChannel("exec");
|
|
||||||
channel.setCommand(command);
|
|
||||||
channel.setErrStream(System.err);
|
|
||||||
channel.connect();
|
|
||||||
|
|
||||||
// 等待命令执行完成
|
|
||||||
while (!channel.isClosed()) {
|
|
||||||
Thread.sleep(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (channel != null) {
|
|
||||||
channel.disconnect();
|
|
||||||
}
|
|
||||||
if (session != null) {
|
|
||||||
session.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,10 @@
|
|||||||
package cd.casic.ci.process.properties;
|
package cd.casic.ci.process.properties;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "target.file-upload")
|
@ConfigurationProperties(prefix = "target.file-upload")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user