diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/ApiComputeResult.java b/backend/src/main/java/io/metersphere/api/dto/definition/ApiComputeResult.java index d00a14e682..25deedccc0 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/ApiComputeResult.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/ApiComputeResult.java @@ -7,7 +7,9 @@ import lombok.Setter; @Setter public class ApiComputeResult { private String apiDefinitionId; - private String caseTotal; + private int caseTotal; private String status; private String passRate; + private int success; + private int error; } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 925589dd48..5cc5178dd0 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -79,7 +79,7 @@ public class ApiDefinitionService { private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; public List list(ApiDefinitionRequest request) { - request = this.initRequest(request,true,true); + request = this.initRequest(request, true, true); List resList = extApiDefinitionMapper.list(request); calculateResult(resList); return resList; @@ -87,16 +87,17 @@ public class ApiDefinitionService { /** * 初始化部分参数 + * * @param request * @param setDefultOrders * @param checkThisWeekData * @return */ - private ApiDefinitionRequest initRequest(ApiDefinitionRequest request,boolean setDefultOrders, boolean checkThisWeekData) { - if(setDefultOrders){ + private ApiDefinitionRequest initRequest(ApiDefinitionRequest request, boolean setDefultOrders, boolean checkThisWeekData) { + if (setDefultOrders) { request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); } - if(checkThisWeekData){ + if (checkThisWeekData) { if (request.isSelectThisWeedData()) { Map weekFirstTimeAndLastTime = DateUtils.getWeedFirstTimeAndLastTime(new Date()); Date weekFirstTime = weekFirstTimeAndLastTime.get("firstTime"); @@ -568,9 +569,16 @@ public class ApiDefinitionService { for (ApiDefinitionResult res : resList) { ApiComputeResult compRes = resultMap.get(res.getId()); if (compRes != null) { - res.setCaseTotal(compRes.getCaseTotal()); + res.setCaseTotal(String.valueOf(compRes.getCaseTotal())); res.setCasePassingRate(compRes.getPassRate()); - res.setCaseStatus(compRes.getStatus()); + // 状态优先级 未执行,未通过,通过 + if ((compRes.getError() + compRes.getSuccess()) < compRes.getCaseTotal()) { + res.setCaseStatus("未执行"); + } else if (compRes.getError() > 0) { + res.setCaseStatus("未通过"); + } else { + res.setCaseStatus("通过"); + } } else { res.setCaseTotal("-"); res.setCasePassingRate("-"); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index cfc38a71c6..312a471fe4 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -89,10 +89,11 @@