deason 2 anos atrás
pai
commit
73ed2db673

+ 20 - 3
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamRecordDataController.java

@@ -8,6 +8,9 @@ import cn.com.qmth.examcloud.core.oe.admin.dao.entity.ExamRecordDataEntity;
 import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordDataSyncService;
 import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
 import io.swagger.annotations.Api;
+import org.apache.commons.collections.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -17,12 +20,13 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.ArrayList;
 import java.util.List;
 
-
 @RestController
 @Api(tags = "考试记录相关接口")
 @RequestMapping("${$rmp.ctr.oe}/exam/record/data")
 public class ExamRecordDataController {
 
+    private static final Logger log = LoggerFactory.getLogger(ExamRecordDataController.class);
+
     @Autowired
     private ExamRecordDataRepo examRecordDataRepo;
 
@@ -34,10 +38,17 @@ public class ExamRecordDataController {
         if (fromCache != null) {
             examRecordDataId = examRecordDataSyncService.getExamRecordDataIdByCacheId(examRecordDataId);
             if (examRecordDataId == null) {
-                throw new StatusException("1001", "未找到数据");
+                log.warn("ExamRecordDataEntity not exist, id:{}", examRecordDataId);
+                throw new StatusException("1001", "当前考试记录信息不存在");
             }
         }
+
         ExamRecordDataEntity examRecordDataEntity = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
+        if (examRecordDataEntity == null) {
+            log.warn("ExamRecordDataEntity not exist, id:{}", examRecordDataId);
+            throw new StatusException("1001", "当前考试记录信息不存在");
+        }
+
         ExamRecordDataDomain domain = ExamRecordDataBeanConvert.copyFrom(examRecordDataEntity);
         domain.setExamRecord(examRecordDataEntity);
         return domain;
@@ -46,12 +57,18 @@ public class ExamRecordDataController {
     @GetMapping("/findByExamStudentId")
     public List<ExamRecordDataDomain> findByExamStudentId(@RequestParam Long examStudentId) {
         List<ExamRecordDataEntity> examRecordEntities = examRecordDataRepo.findByExamStudentId(examStudentId);
-        List<ExamRecordDataDomain> examRecordDataList = new ArrayList<ExamRecordDataDomain>();
+
+        List<ExamRecordDataDomain> examRecordDataList = new ArrayList<>();
+        if (CollectionUtils.isEmpty(examRecordEntities)) {
+            return examRecordDataList;
+        }
+
         for (ExamRecordDataEntity examRecordData : examRecordEntities) {
             ExamRecordDataDomain domain = ExamRecordDataBeanConvert.copyFrom(examRecordData);
             domain.setExamRecord(examRecordData);
             examRecordDataList.add(domain);
         }
+
         return examRecordDataList;
     }
 

+ 8 - 1
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/client/ExamProcessController.java

@@ -138,10 +138,17 @@ public class ExamProcessController extends ControllerSupport {
         if (fromCache != null) {
             examRecordDataId = examRecordDataSyncService.getExamRecordDataIdByCacheId(examRecordDataId);
             if (examRecordDataId == null) {
-                throw new StatusException("1001", "未找到数据");
+                log.warn("ExamRecordDataEntity not exist, id:{}", examRecordDataId);
+                throw new StatusException("1001", "当前考试记录信息不存在");
             }
         }
+
         ExamRecordDataEntity examRecordDataEntity = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
+        if (examRecordDataEntity == null) {
+            log.warn("ExamRecordDataEntity not exist, id:{}", examRecordDataId);
+            throw new StatusException("1001", "当前考试记录信息不存在");
+        }
+
         ExamRecordDataDomain domain = ExamRecordDataBeanConvert.copyFrom(examRecordDataEntity);
         domain.setExamRecord(examRecordDataEntity);
         return domain;