fix(测试跟踪): 修复测试计划报告分享,点击用例报告显示链接失效的缺陷

--bug=1023967 --user=王孝刚
[接口测试]github#22405测试报告链接有效期设置为15天,两三天后点击测试报告链接进去查看失败用例详情报错
https://www.tapd.cn/55049933/s/1345056
This commit is contained in:
wxg0103 2023-03-02 17:52:06 +08:00 committed by jianxing
parent c389ebbdf8
commit c77f04e2d4
13 changed files with 119 additions and 34 deletions

View File

@ -11,4 +11,6 @@ public interface ExtTestPlanApiScenarioMapper {
List<TestPlanApiScenario> selectPlanByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids); List<TestPlanApiScenario> selectPlanByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
List<TestPlanApiScenario> selectByScenarioIds(@Param("ids") List<String> ids); List<TestPlanApiScenario> selectByScenarioIds(@Param("ids") List<String> ids);
String selectPlanIdByTestPlanId(@Param("id") String id);
} }

View File

@ -38,4 +38,9 @@
#{v} #{v}
</foreach> </foreach>
</select> </select>
<select id="selectPlanIdByTestPlanId" resultType="java.lang.String">
SELECT plan.project_id from test_plan plan LEFT JOIN
test_plan_report report on plan.id = report.test_plan_id
where report.id =#{id}
</select>
</mapper> </mapper>

View File

@ -3,12 +3,12 @@ package io.metersphere.controller.plan;
import io.metersphere.api.dto.automation.TestPlanFailureApiDTO; import io.metersphere.api.dto.automation.TestPlanFailureApiDTO;
import io.metersphere.service.ShareInfoService; import io.metersphere.service.ShareInfoService;
import io.metersphere.service.plan.TestPlanApiCaseService; import io.metersphere.service.plan.TestPlanApiCaseService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;
import java.util.List; import java.util.List;
@RestController @RestController
@ -22,25 +22,25 @@ public class ShareTestPlanApiCaseController {
@GetMapping("/list/failure/{shareId}/{planId}") @GetMapping("/list/failure/{shareId}/{planId}")
public List<TestPlanFailureApiDTO> getApiFailureList(@PathVariable String shareId, @PathVariable String planId) { public List<TestPlanFailureApiDTO> getApiFailureList(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId);
return testPlanApiCaseService.getFailureCases(planId); return testPlanApiCaseService.getFailureCases(planId);
} }
@GetMapping("/list/errorReport/{shareId}/{planId}") @GetMapping("/list/errorReport/{shareId}/{planId}")
public List<TestPlanFailureApiDTO> getErrorReportApiCaseList(@PathVariable String shareId, @PathVariable String planId) { public List<TestPlanFailureApiDTO> getErrorReportApiCaseList(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId);
return testPlanApiCaseService.getErrorReportCases(planId); return testPlanApiCaseService.getErrorReportCases(planId);
} }
@GetMapping("/list/unExecute/{shareId}/{planId}") @GetMapping("/list/unExecute/{shareId}/{planId}")
public List<TestPlanFailureApiDTO> getUnExecuteCases(@PathVariable String shareId, @PathVariable String planId) { public List<TestPlanFailureApiDTO> getUnExecuteCases(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId);
return testPlanApiCaseService.getUnExecuteCases(planId); return testPlanApiCaseService.getUnExecuteCases(planId);
} }
@GetMapping("/list/all/{shareId}/{planId}") @GetMapping("/list/all/{shareId}/{planId}")
public List<TestPlanFailureApiDTO> getApiAllList(@PathVariable String shareId, @PathVariable String planId) { public List<TestPlanFailureApiDTO> getApiAllList(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId);
return testPlanApiCaseService.getAllCases(planId); return testPlanApiCaseService.getAllCases(planId);
} }
} }

View File

@ -3,13 +3,12 @@ package io.metersphere.controller.plan;
import io.metersphere.api.dto.ApiReportResult; import io.metersphere.api.dto.ApiReportResult;
import io.metersphere.service.ShareInfoService; import io.metersphere.service.ShareInfoService;
import io.metersphere.service.definition.ApiDefinitionService; import io.metersphere.service.definition.ApiDefinitionService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;
@RestController @RestController
@RequestMapping("/share") @RequestMapping("/share")
public class ShareTestPlanApiReportController { public class ShareTestPlanApiReportController {
@ -21,7 +20,7 @@ public class ShareTestPlanApiReportController {
@GetMapping("/api/definition/report/getReport/{shareId}/{testId}") @GetMapping("/api/definition/report/getReport/{shareId}/{testId}")
public ApiReportResult getApiReport(@PathVariable String shareId, @PathVariable String testId) { public ApiReportResult getApiReport(@PathVariable String shareId, @PathVariable String testId) {
shareInfoService.validateExpired(shareId); shareInfoService.validate(shareId);
return apiDefinitionService.getDbResult(testId); return apiDefinitionService.getDbResult(testId);
} }
} }

View File

@ -1,14 +1,16 @@
package io.metersphere.controller.plan; package io.metersphere.controller.plan;
import io.metersphere.api.dto.automation.ApiScenarioReportResult;
import io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO; import io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO;
import io.metersphere.service.ShareInfoService; import io.metersphere.service.ShareInfoService;
import io.metersphere.service.plan.TestPlanScenarioCaseService; import io.metersphere.service.plan.TestPlanScenarioCaseService;
import io.metersphere.service.scenario.ApiScenarioReportService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;
import java.util.List; import java.util.List;
@RestController @RestController
@ -19,28 +21,37 @@ public class ShareTestPlanScenarioCaseController {
ShareInfoService shareInfoService; ShareInfoService shareInfoService;
@Resource @Resource
TestPlanScenarioCaseService testPlanScenarioCaseService; TestPlanScenarioCaseService testPlanScenarioCaseService;
@Resource
private ApiScenarioReportService apiReportService;
@GetMapping("/list/failure/{shareId}/{planId}") @GetMapping("/list/failure/{shareId}/{planId}")
public List<TestPlanFailureScenarioDTO> getScenarioFailureList(@PathVariable String shareId, @PathVariable String planId) { public List<TestPlanFailureScenarioDTO> getScenarioFailureList(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId);
return testPlanScenarioCaseService.getFailureCases(planId); return testPlanScenarioCaseService.getFailureCases(planId);
} }
@GetMapping("/list/all/{shareId}/{planId}") @GetMapping("/list/all/{shareId}/{planId}")
public List<TestPlanFailureScenarioDTO> getScenarioAllList(@PathVariable String shareId, @PathVariable String planId) { public List<TestPlanFailureScenarioDTO> getScenarioAllList(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId);
return testPlanScenarioCaseService.getAllCases(planId); return testPlanScenarioCaseService.getAllCases(planId);
} }
@GetMapping("/list/errorReport/{shareId}/{planId}") @GetMapping("/list/errorReport/{shareId}/{planId}")
public List<TestPlanFailureScenarioDTO> getScenarioErrorReportList(@PathVariable String shareId, @PathVariable String planId) { public List<TestPlanFailureScenarioDTO> getScenarioErrorReportList(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId);
return testPlanScenarioCaseService.getErrorReportCases(planId); return testPlanScenarioCaseService.getErrorReportCases(planId);
} }
@GetMapping("/list/unExecute/{shareId}/{planId}") @GetMapping("/list/unExecute/{shareId}/{planId}")
public List<TestPlanFailureScenarioDTO> getUnExecuteScenarioCases(@PathVariable String shareId, @PathVariable String planId) { public List<TestPlanFailureScenarioDTO> getUnExecuteScenarioCases(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId);
return testPlanScenarioCaseService.getUnExecuteCases(planId); return testPlanScenarioCaseService.getUnExecuteCases(planId);
} }
@GetMapping("/get/{shareId}/{reportId}")
public ApiScenarioReportResult get(@PathVariable String shareId, @PathVariable String reportId) {
shareInfoService.validate(shareId);
return apiReportService.get(reportId, true);
}
} }

View File

@ -13,6 +13,7 @@ import io.metersphere.base.mapper.ShareInfoMapper;
import io.metersphere.base.mapper.UserMapper; import io.metersphere.base.mapper.UserMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper;
import io.metersphere.base.mapper.ext.ExtShareInfoMapper; import io.metersphere.base.mapper.ext.ExtShareInfoMapper;
import io.metersphere.base.mapper.plan.ext.ExtTestPlanApiScenarioMapper;
import io.metersphere.commons.constants.ProjectApplicationType; import io.metersphere.commons.constants.ProjectApplicationType;
import io.metersphere.commons.constants.PropertyConstant; import io.metersphere.commons.constants.PropertyConstant;
import io.metersphere.commons.constants.ShareType; import io.metersphere.commons.constants.ShareType;
@ -21,15 +22,16 @@ import io.metersphere.commons.utils.*;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import io.metersphere.service.definition.ApiModuleService; import io.metersphere.service.definition.ApiModuleService;
import io.metersphere.service.scenario.ApiScenarioReportService; import io.metersphere.service.scenario.ApiScenarioReportService;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings; import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -58,6 +60,8 @@ public class ShareInfoService extends BaseShareInfoService {
private ApiScenarioReportService apiScenarioReportService; private ApiScenarioReportService apiScenarioReportService;
@Resource @Resource
private BaseProjectApplicationService baseProjectApplicationService; private BaseProjectApplicationService baseProjectApplicationService;
@Resource
ExtTestPlanApiScenarioMapper extTestPlanApiScenarioMapper;
public Pager<List<ApiDocumentInfoDTO>> selectApiInfoByParam(ApiDocumentRequest apiDocumentRequest, int goPage, int pageSize) { public Pager<List<ApiDocumentInfoDTO>> selectApiInfoByParam(ApiDocumentRequest apiDocumentRequest, int goPage, int pageSize) {
this.iniApiDocumentRequest(apiDocumentRequest); this.iniApiDocumentRequest(apiDocumentRequest);
@ -627,15 +631,14 @@ public class ShareInfoService extends BaseShareInfoService {
} }
} }
public void validate(String shareId, String customData) { public void validate(String shareId) {
ShareInfo shareInfo = shareInfoMapper.selectByPrimaryKey(shareId); ShareInfo shareInfo = shareInfoMapper.selectByPrimaryKey(shareId);
validateExpired(shareInfo); if (ObjectUtils.isNotEmpty(shareInfo)) {
String projectId = extTestPlanApiScenarioMapper.selectPlanIdByTestPlanId(shareInfo.getCustomData());
validateExpiredTestPlan(shareInfo, projectId);
}
if (shareInfo == null) { if (shareInfo == null) {
MSException.throwException("ShareInfo not exist!"); MSException.throwException("ShareInfo not exist!");
} else {
if (!StringUtils.equals(customData, shareInfo.getCustomData())) {
MSException.throwException("ShareInfo validate failure!");
}
} }
} }
} }

View File

@ -37,6 +37,10 @@ export function getShareScenarioReport(shareId, reportId) {
return get('/api/scenario/report/get/' + shareId + '/' + reportId); return get('/api/scenario/report/get/' + shareId + '/' + reportId);
} }
export function getSharePlanScenarioReport(shareId, reportId) {
return get('/share/test/plan/scenario/case/get/' + shareId + '/' + reportId);
}
export function getScenarioReportStepDetail(stepId) { export function getScenarioReportStepDetail(stepId) {
return get('/api/scenario/report/get/step/detail/' + stepId); return get('/api/scenario/report/get/step/detail/' + stepId);
} }

View File

@ -126,6 +126,7 @@ import {
getScenarioReport, getScenarioReport,
getScenarioReportDetail, getScenarioReportDetail,
getShareScenarioReport, getShareScenarioReport,
getSharePlanScenarioReport,
reportReName, reportReName,
} from '../../../api/scenario-report'; } from '../../../api/scenario-report';
import { STEP } from '../../automation/scenario/Setting'; import { STEP } from '../../automation/scenario/Setting';
@ -459,6 +460,15 @@ export default {
this.buildReport(); this.buildReport();
} }
} else if (this.isShare) { } else if (this.isShare) {
if (this.isPlan) {
getSharePlanScenarioReport(this.shareId, this.reportId).then((res) => {
let data = res.data;
if (data) {
this.checkReport(data);
this.handleGetScenarioReport(data);
}
});
}
if (this.reportId) { if (this.reportId) {
getShareScenarioReport(this.shareId, this.reportId).then((res) => { getShareScenarioReport(this.shareId, this.reportId).then((res) => {
let data = res.data; let data = res.data;

View File

@ -1,17 +1,25 @@
package io.metersphere.service; package io.metersphere.service;
import io.metersphere.base.domain.ProjectApplication;
import io.metersphere.base.domain.ShareInfo; import io.metersphere.base.domain.ShareInfo;
import io.metersphere.base.mapper.ShareInfoMapper; import io.metersphere.base.mapper.ShareInfoMapper;
import io.metersphere.base.mapper.ext.BaseShareInfoMapper; import io.metersphere.base.mapper.ext.BaseShareInfoMapper;
import io.metersphere.commons.constants.ProjectApplicationType;
import io.metersphere.commons.exception.MSException;
import io.metersphere.dto.ShareInfoDTO; import io.metersphere.dto.ShareInfoDTO;
import io.metersphere.i18n.Translator;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import static io.metersphere.commons.user.ShareUtil.getTimeMills;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class BaseShareInfoService { public class BaseShareInfoService {
@ -20,6 +28,8 @@ public class BaseShareInfoService {
BaseShareInfoMapper baseShareInfoMapper; BaseShareInfoMapper baseShareInfoMapper;
@Resource @Resource
ShareInfoMapper shareInfoMapper; ShareInfoMapper shareInfoMapper;
@Resource
private BaseProjectApplicationService baseProjectApplicationService;
/** /**
* 生成分享连接 * 生成分享连接
@ -60,4 +70,35 @@ public class BaseShareInfoService {
public ShareInfo get(String id) { public ShareInfo get(String id) {
return shareInfoMapper.selectByPrimaryKey(id); return shareInfoMapper.selectByPrimaryKey(id);
} }
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void validateExpiredTestPlan(ShareInfo shareInfo, String projectId) {
// 有效期根据类型从ProjectApplication中获取
if (shareInfo == null) {
MSException.throwException(Translator.get("connection_expired"));
}
String type = ProjectApplicationType.TRACK_SHARE_REPORT_TIME.toString();
if (StringUtils.isBlank(type) || Strings.isBlank(projectId)) {
millisCheck(System.currentTimeMillis() - shareInfo.getUpdateTime(), 1000 * 60 * 60 * 24, shareInfo.getId());
} else {
ProjectApplication projectApplication = baseProjectApplicationService.getProjectApplication(projectId, type);
if (projectApplication.getTypeValue() == null) {
millisCheck(System.currentTimeMillis() - shareInfo.getUpdateTime(), 1000 * 60 * 60 * 24, shareInfo.getId());
} else {
String expr = projectApplication.getTypeValue();
long timeMills = getTimeMills(shareInfo.getUpdateTime(), expr);
millisCheck(System.currentTimeMillis(), timeMills, shareInfo.getId());
}
}
}
private void millisCheck(long compareMillis, long millis, String shareInfoId) {
if (compareMillis > millis) {
shareInfoMapper.deleteByPrimaryKey(shareInfoId);
MSException.throwException(Translator.get("connection_expired"));
}
}
} }

View File

@ -41,4 +41,6 @@ public interface ExtTestPlanLoadCaseMapper {
List<String> selectIdByLoadCaseReportIdAndStatusIsRun(String reportId); List<String> selectIdByLoadCaseReportIdAndStatusIsRun(String reportId);
void updateStatusNullById(String id); void updateStatusNullById(String id);
String selectPlanIdByTestPlanId(@Param("id") String id);
} }

View File

@ -348,6 +348,11 @@
where load_report_id = #{planId} where load_report_id = #{planId}
and `status` = 'run' and `status` = 'run'
</select> </select>
<select id="selectPlanIdByTestPlanId" resultType="java.lang.String">
SELECT plan.project_id from test_plan plan LEFT JOIN
test_plan_report report on plan.id = report.test_plan_id
where report.id =#{id}
</select>
<update id="updateStatusNullById"> <update id="updateStatusNullById">
update test_plan_load_case tplc update test_plan_load_case tplc
set status = null set status = null

View File

@ -4,9 +4,9 @@ import io.metersphere.plan.dto.TestPlanLoadCaseDTO;
import io.metersphere.plan.request.LoadCaseReportRequest; import io.metersphere.plan.request.LoadCaseReportRequest;
import io.metersphere.plan.service.TestPlanLoadCaseService; import io.metersphere.plan.service.TestPlanLoadCaseService;
import io.metersphere.service.ShareInfoService; import io.metersphere.service.ShareInfoService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import java.util.List; import java.util.List;
@RestController @RestController
@ -20,19 +20,19 @@ public class ShareTestPlanLoadCaseController {
@GetMapping("/list/failure/{shareId}/{planId}") @GetMapping("/list/failure/{shareId}/{planId}")
public List<TestPlanLoadCaseDTO> getLoadFailureCases(@PathVariable String shareId, @PathVariable String planId) { public List<TestPlanLoadCaseDTO> getLoadFailureCases(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId);
return testPlanLoadCaseService.getFailureCases(planId); return testPlanLoadCaseService.getFailureCases(planId);
} }
@GetMapping("/list/all/{shareId}/{planId}") @GetMapping("/list/all/{shareId}/{planId}")
public List<TestPlanLoadCaseDTO> getLoadAllCases(@PathVariable String shareId, @PathVariable String planId) { public List<TestPlanLoadCaseDTO> getLoadAllCases(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId); shareInfoService.validate(shareId);
return testPlanLoadCaseService.getAllCases(planId); return testPlanLoadCaseService.getAllCases(planId);
} }
@PostMapping("/report/exist/{shareId}") @PostMapping("/report/exist/{shareId}")
public Boolean isExistReport(@PathVariable String shareId, @RequestBody LoadCaseReportRequest request) { public Boolean isExistReport(@PathVariable String shareId, @RequestBody LoadCaseReportRequest request) {
shareInfoService.validateExpired(shareId); shareInfoService.validate(shareId);
return testPlanLoadCaseService.isExistReport(request); return testPlanLoadCaseService.isExistReport(request);
} }
} }

View File

@ -5,42 +5,45 @@ import io.metersphere.base.domain.ProjectApplication;
import io.metersphere.base.domain.ShareInfo; import io.metersphere.base.domain.ShareInfo;
import io.metersphere.base.mapper.LoadTestReportMapper; import io.metersphere.base.mapper.LoadTestReportMapper;
import io.metersphere.base.mapper.ShareInfoMapper; import io.metersphere.base.mapper.ShareInfoMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper;
import io.metersphere.commons.constants.ProjectApplicationType; import io.metersphere.commons.constants.ProjectApplicationType;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings; import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import static io.metersphere.commons.user.ShareUtil.getTimeMills; import static io.metersphere.commons.user.ShareUtil.getTimeMills;
@Service @Service
public class ShareInfoService { public class ShareInfoService extends BaseShareInfoService {
@Resource @Resource
private ShareInfoMapper shareInfoMapper; private ShareInfoMapper shareInfoMapper;
@Resource @Resource
private BaseProjectApplicationService baseProjectApplicationService; private BaseProjectApplicationService baseProjectApplicationService;
@Resource @Resource
private LoadTestReportMapper loadTestReportMapper; private LoadTestReportMapper loadTestReportMapper;
@Resource
private ExtTestPlanLoadCaseMapper extTestPlanLoadCaseMapper;
public void validateExpired(String shareId) { public void validateExpired(String shareId) {
ShareInfo shareInfo = shareInfoMapper.selectByPrimaryKey(shareId); ShareInfo shareInfo = shareInfoMapper.selectByPrimaryKey(shareId);
this.validateExpired(shareInfo); this.validateExpired(shareInfo);
} }
public void validate(String shareId, String customData) { public void validate(String shareId) {
ShareInfo shareInfo = shareInfoMapper.selectByPrimaryKey(shareId); ShareInfo shareInfo = shareInfoMapper.selectByPrimaryKey(shareId);
validateExpired(shareInfo); if (ObjectUtils.isNotEmpty(shareInfo)) {
String projectId = extTestPlanLoadCaseMapper.selectPlanIdByTestPlanId(shareInfo.getCustomData());
validateExpiredTestPlan(shareInfo, projectId);
}
if (shareInfo == null) { if (shareInfo == null) {
MSException.throwException("ShareInfo not exist!"); MSException.throwException("ShareInfo not exist!");
} else {
if (!StringUtils.equals(customData, shareInfo.getCustomData())) {
MSException.throwException("ShareInfo validate failure!");
}
} }
} }