lyhzzz 3 semanas atrás
pai
commit
3c7f6d29d9

+ 12 - 3
src/main/java/com/fdkankan/fusion/service/impl/SceneService.java

@@ -212,10 +212,19 @@ public class SceneService implements ISceneService {
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
         List<CaseNumEntity> caseNumEntities = caseNumService.getByNum(num);
-        if(caseNumEntities.size() >0){
-            CaseNumEntity caseNumEntity = caseNumEntities.get(0);
+        for (CaseNumEntity caseNumEntity : caseNumEntities) {
             CaseEntity caseEntity = caseService.getById(caseNumEntity.getCaseId());
-            throw new BusinessException(ResultCode.CASE_USE.code, String.format(ResultCode.CASE_USE.msg,caseEntity.getCaseTitle()));
+            if(caseEntity == null){
+                continue;
+            }
+            if( caseEntity.getTmProjectId() != null){
+                TmProject tmProject = tmProjectService.getById(caseEntity.getTmProjectId());
+                if(tmProject!=null){
+                    throw new BusinessException(ResultCode.CASE_USE.code, String.format(ResultCode.CASE_USE.msg,tmProject.getProjectName()));
+                }
+            }else {
+                throw new BusinessException(ResultCode.CASE_USE.code, String.format(ResultCode.CASE_USE.msg,caseEntity.getCaseTitle()));
+            }
         }
         fdService.deleteNum(num);
     }