refactor(接口测试): 优化接口代码
This commit is contained in:
parent
2e08868d98
commit
d7257ddee8
|
@ -27,7 +27,7 @@ public interface ExtApiReportMapper {
|
||||||
|
|
||||||
List<String> selectApiReportByProjectIdAndTime(@Param("time") long time, @Param("projectId") String projectId);
|
List<String> selectApiReportByProjectIdAndTime(@Param("time") long time, @Param("projectId") String projectId);
|
||||||
|
|
||||||
int selectApiReportByTime(@Param("time") long time, @Param("projectId") String projectId);
|
int countApiReportByTime(@Param("time") long time, @Param("projectId") String projectId);
|
||||||
|
|
||||||
List<TaskCenterDTO> taskCenterlist(@Param("request") TaskCenterPageRequest request, @Param("projectIds") List<String> projectIds,
|
List<TaskCenterDTO> taskCenterlist(@Param("request") TaskCenterPageRequest request, @Param("projectIds") List<String> projectIds,
|
||||||
@Param("startTime") long startTime, @Param("endTime") long endTime);
|
@Param("startTime") long startTime, @Param("endTime") long endTime);
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
where api_report.project_id = #{projectId}
|
where api_report.project_id = #{projectId}
|
||||||
limit 500
|
limit 500
|
||||||
</select>
|
</select>
|
||||||
<select id="selectApiReportByTime" resultType="java.lang.Integer">
|
<select id="countApiReportByTime" resultType="java.lang.Integer">
|
||||||
select
|
select
|
||||||
count(api_report.id)
|
count(api_report.id)
|
||||||
from api_report inner join api_report_step on
|
from api_report inner join api_report_step on
|
||||||
|
|
|
@ -26,9 +26,8 @@ public interface ExtApiScenarioReportMapper {
|
||||||
|
|
||||||
List<String> selectApiScenarioReportByProjectId(String projectId);
|
List<String> selectApiScenarioReportByProjectId(String projectId);
|
||||||
|
|
||||||
int selectReportByTime(@Param("time") long time, @Param("projectId") String projectId);
|
|
||||||
|
|
||||||
int selectScenarioReportByTime(@Param("time") long time, @Param("projectId") String projectId);
|
int countScenarioReportByTime(@Param("time") long time, @Param("projectId") String projectId);
|
||||||
|
|
||||||
List<String> selectApiReportByProjectIdAndTime(@Param("time") long time, @Param("projectId") String projectId);
|
List<String> selectApiReportByProjectIdAndTime(@Param("time") long time, @Param("projectId") String projectId);
|
||||||
|
|
||||||
|
|
|
@ -84,15 +84,7 @@
|
||||||
api_scenario_report.id
|
api_scenario_report.id
|
||||||
from api_scenario_report where api_scenario_report.project_id = #{projectId} limit 500
|
from api_scenario_report where api_scenario_report.project_id = #{projectId} limit 500
|
||||||
</select>
|
</select>
|
||||||
<select id="selectReportByTime" resultType="java.lang.Integer">
|
<select id="countScenarioReportByTime" resultType="java.lang.Integer">
|
||||||
select
|
|
||||||
api_scenario_report.id
|
|
||||||
from api_scenario_report inner join api_scenario_report_step on
|
|
||||||
api_scenario_report.id = api_scenario_report_step.report_id
|
|
||||||
where api_scenario_report.start_time >= #{startTime}
|
|
||||||
and api_scenario_report.start_time <= #{endTime}
|
|
||||||
</select>
|
|
||||||
<select id="selectScenarioReportByTime" resultType="java.lang.Integer">
|
|
||||||
select
|
select
|
||||||
count(api_scenario_report.id)
|
count(api_scenario_report.id)
|
||||||
from api_scenario_report inner join api_scenario_report_step on
|
from api_scenario_report inner join api_scenario_report_step on
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class CleanupApiReportServiceImpl implements BaseCleanUpReport {
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关接口测试报告");
|
LogUtils.info("清理当前项目[" + projectId + "]相关接口测试报告");
|
||||||
String expr = map.get(ProjectApplicationType.API.API_CLEAN_REPORT.name());
|
String expr = map.get(ProjectApplicationType.API.API_CLEAN_REPORT.name());
|
||||||
long timeMills = getCleanDate(expr);
|
long timeMills = getCleanDate(expr);
|
||||||
int apiReportCount = extApiReportMapper.selectApiReportByTime(timeMills, projectId);
|
int apiReportCount = extApiReportMapper.countApiReportByTime(timeMills, projectId);
|
||||||
while (apiReportCount > 0) {
|
while (apiReportCount > 0) {
|
||||||
List<String> ids = extApiReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId);
|
List<String> ids = extApiReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId);
|
||||||
ApiReportExample reportExample = new ApiReportExample();
|
ApiReportExample reportExample = new ApiReportExample();
|
||||||
|
@ -53,9 +53,9 @@ public class CleanupApiReportServiceImpl implements BaseCleanUpReport {
|
||||||
report.setDeleted(true);
|
report.setDeleted(true);
|
||||||
apiReportMapper.updateByExampleSelective(report, reportExample);
|
apiReportMapper.updateByExampleSelective(report, reportExample);
|
||||||
deleteApiReport(ids);
|
deleteApiReport(ids);
|
||||||
apiReportCount = extApiReportMapper.selectApiReportByTime(timeMills, projectId);
|
apiReportCount = extApiReportMapper.countApiReportByTime(timeMills, projectId);
|
||||||
}
|
}
|
||||||
int scenarioReportCount = extApiScenarioReportMapper.selectScenarioReportByTime(timeMills, projectId);
|
int scenarioReportCount = extApiScenarioReportMapper.countScenarioReportByTime(timeMills, projectId);
|
||||||
while (scenarioReportCount > 0) {
|
while (scenarioReportCount > 0) {
|
||||||
List<String> ids = extApiScenarioReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId);
|
List<String> ids = extApiScenarioReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId);
|
||||||
ApiScenarioReportExample reportExample = new ApiScenarioReportExample();
|
ApiScenarioReportExample reportExample = new ApiScenarioReportExample();
|
||||||
|
@ -64,7 +64,7 @@ public class CleanupApiReportServiceImpl implements BaseCleanUpReport {
|
||||||
report.setDeleted(true);
|
report.setDeleted(true);
|
||||||
apiScenarioReportMapper.updateByExampleSelective(report, reportExample);
|
apiScenarioReportMapper.updateByExampleSelective(report, reportExample);
|
||||||
deleteScenarioReport(ids);
|
deleteScenarioReport(ids);
|
||||||
scenarioReportCount = extApiScenarioReportMapper.selectScenarioReportByTime(timeMills, projectId);
|
scenarioReportCount = extApiScenarioReportMapper.countScenarioReportByTime(timeMills, projectId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -175,7 +176,7 @@ public class MockServerService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return StringUtils.equals(new String(binaryFile), new String(bytes));
|
return Arrays.equals(bytes, binaryFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue