deason 5 år sedan
förälder
incheckning
2e99fa7da1

+ 1 - 1
examcloud-core-print-common/src/main/java/cn/com/qmth/examcloud/core/print/common/jpa/Model.java

@@ -23,7 +23,7 @@ public class Model {
 
     public static <T> T of(Optional<T> optional) {
         try {
-            if (optional != null) {
+            if (optional.isPresent()) {
                 return optional.get();
             }
         } catch (NoSuchElementException e) {

+ 1 - 0
examcloud-core-print-common/src/main/java/cn/com/qmth/examcloud/core/print/common/utils/ElectronUtils.java

@@ -109,6 +109,7 @@ public class ElectronUtils {
             log.error(e.getMessage(), e);
         } catch (InterruptedException e) {
             log.error(e.getMessage(), e);
+            Thread.currentThread().interrupt();
         } finally {
             if (process != null) {
                 process.destroy();

+ 4 - 3
examcloud-core-print-provider/src/main/java/cn/com/qmth/examcloud/core/print/api/controller/CommonController.java

@@ -10,7 +10,6 @@ package cn.com.qmth.examcloud.core.print.api.controller;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.print.common.Result;
 import cn.com.qmth.examcloud.core.print.common.upyun.UpYunClient;
-import cn.com.qmth.examcloud.core.print.common.utils.Check;
 import cn.com.qmth.examcloud.core.print.common.utils.FileUtils;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.web.support.Naked;
@@ -27,6 +26,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
 
+import static cn.com.qmth.examcloud.core.print.common.Constants.SYS_CODE_400;
 import static cn.com.qmth.examcloud.core.print.common.Constants.SYS_CODE_500;
 
 /**
@@ -55,8 +55,9 @@ public class CommonController extends ControllerSupport {
             log.warn(e.getMessage());
         }
 
-        Check.isNull(file, "上传的文件不能为空!");
-        Check.isTrue(file.isEmpty(), "上传的文件不能为空!");
+        if (file == null || file.isEmpty()) {
+            throw new StatusException(SYS_CODE_400, "上传的文件不能为空!");
+        }
 
         String fileUrl = upYunClient.upload(file.getBytes(), file.getOriginalFilename());
         if (StringUtils.isNotEmpty(fileUrl)) {

+ 6 - 2
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/impl/CoursePaperServiceImpl.java

@@ -259,10 +259,14 @@ public class CoursePaperServiceImpl implements CoursePaperService {
         Check.isEmpty(coursePaperId, "课程试卷ID不能为空!");
 
         Optional<CourseStatistic> statisticOptional = courseStatisticRepository.findById(courseStatisticId);
-        Check.isFalse(statisticOptional.isPresent(), "当前课程统计不存在!");
+        if (!statisticOptional.isPresent()) {
+            throw new StatusException(SYS_CODE_400, "当前课程统计不存在!");
+        }
 
         Optional<CoursePaper> coursePaperOptional = coursePaperRepository.findById(coursePaperId);
-        Check.isFalse(coursePaperOptional.isPresent(), "当前课程试卷不存在!");
+        if (!coursePaperOptional.isPresent()) {
+            throw new StatusException(SYS_CODE_400, "当前课程试卷不存在!");
+        }
 
         CourseStatistic statistic = statisticOptional.get();
         CoursePaper coursePaper = coursePaperOptional.get();