xiatian vor 4 Jahren
Ursprung
Commit
ca37a1fee2

+ 2 - 8
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/controller/PaperController.java

@@ -271,16 +271,10 @@ public class PaperController extends ControllerSupport {
     @ResponseBody
     @ApiOperation(value = "删除试卷", notes = "删除试卷")
     @DeleteMapping(value = "/paper/{paperIds}")
-    public ResponseEntity<Object> delPaper(@PathVariable String paperIds) {
+    public void delPaper(@PathVariable String paperIds) {
         User user = getAccessUser();
         List<String> paperList = Stream.of(paperIds.split(",")).collect(Collectors.toList());
-        Map<String, Object> msgMap = paperService.deletePapers(paperList, user);
-        if (msgMap.get("msg").equals("success")) {
-            return new ResponseEntity<>(msgMap, HttpStatus.OK);
-        } else {
-            throw new StatusException("1001", "试卷[" + msgMap.get("paperName") + "]中有试题被组卷使用,不能删除!");
-        }
-
+        paperService.deletePapers(paperList, user);
     }
 
     /**

+ 1 - 1
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperService.java

@@ -119,7 +119,7 @@ public interface PaperService {
      *
      * @param paperIds
      */
-    public Map<String, Object> deletePapers(List<String> paperIds, User user);
+    public void deletePapers(List<String> paperIds, User user);
 
     /**
      * 批量通过试卷

+ 90 - 53
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperServiceImpl.java

@@ -1,5 +1,58 @@
 package cn.com.qmth.examcloud.core.questions.service.impl;
 
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.nlpcn.commons.lang.util.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.data.domain.Sort.Order;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.google.gson.Gson;
+
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
@@ -18,10 +71,35 @@ import cn.com.qmth.examcloud.core.questions.base.enums.PaperStatus;
 import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
 import cn.com.qmth.examcloud.core.questions.base.exception.PaperException;
 import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
-import cn.com.qmth.examcloud.core.questions.dao.*;
-import cn.com.qmth.examcloud.core.questions.dao.entity.*;
-import cn.com.qmth.examcloud.core.questions.service.*;
-import cn.com.qmth.examcloud.core.questions.service.bean.dto.*;
+import cn.com.qmth.examcloud.core.questions.dao.ExamPaperRepo;
+import cn.com.qmth.examcloud.core.questions.dao.PaperDetailRepo;
+import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
+import cn.com.qmth.examcloud.core.questions.dao.PaperRepo;
+import cn.com.qmth.examcloud.core.questions.dao.QuesBakRepo;
+import cn.com.qmth.examcloud.core.questions.dao.QuesRepo;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Course;
+import cn.com.qmth.examcloud.core.questions.dao.entity.ExamPaper;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetail;
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnit;
+import cn.com.qmth.examcloud.core.questions.dao.entity.PaperSearchInfo;
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuesOption;
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuesProperty;
+import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionAudio;
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuestionBak;
+import cn.com.qmth.examcloud.core.questions.service.ExtractConfigService;
+import cn.com.qmth.examcloud.core.questions.service.PaperDetailService;
+import cn.com.qmth.examcloud.core.questions.service.PaperDetailUnitService;
+import cn.com.qmth.examcloud.core.questions.service.PaperService;
+import cn.com.qmth.examcloud.core.questions.service.QuesService;
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.DownloadPaperDto;
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.ObjectiveQuestionStructure;
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailExp;
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailUnitExp;
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperExp;
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperQuestionStructureInfo;
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.SubjectiveQuestionStructure;
 import cn.com.qmth.examcloud.core.questions.service.bean.paper.PaperAnswerDomain;
 import cn.com.qmth.examcloud.core.questions.service.cache.BasePaperCache;
 import cn.com.qmth.examcloud.core.questions.service.cache.ExtractConfigPaperCache;
@@ -37,39 +115,6 @@ import cn.com.qmth.examcloud.web.config.SystemProperties;
 import cn.com.qmth.examcloud.web.filestorage.FileStoragePathEnvInfo;
 import cn.com.qmth.examcloud.web.filestorage.YunPathInfo;
 import cn.com.qmth.examcloud.web.support.SpringContextHolder;
-import com.google.gson.Gson;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.xssf.usermodel.XSSFCell;
-import org.apache.poi.xssf.usermodel.XSSFRow;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.nlpcn.commons.lang.util.StringUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.*;
-import org.springframework.data.domain.Sort.Direction;
-import org.springframework.data.domain.Sort.Order;
-import org.springframework.data.mongodb.core.MongoTemplate;
-import org.springframework.data.mongodb.core.query.Criteria;
-import org.springframework.data.mongodb.core.query.Query;
-import org.springframework.stereotype.Service;
-import org.springframework.util.Assert;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.io.*;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
 
 /**
  * @author chenken
@@ -526,10 +571,7 @@ public class PaperServiceImpl implements PaperService {
      *
      * @param paperIds
      */
-    @SuppressWarnings("unchecked")
-    public Map<String, Object> deletePapers(List<String> paperIds, User user) {
-        Map<String, Object> msgMap = new HashMap<>();
-        String msg = "";
+    public void deletePapers(List<String> paperIds, User user) {
         List<Paper> papers = CommonUtils.toList(paperRepo.findByIdIn(paperIds));
         if (papers.get(0).getPaperType() == PaperType.IMPORT) {
             List<Question> quesList = new ArrayList<>();
@@ -544,10 +586,11 @@ public class PaperServiceImpl implements PaperService {
             List<PaperDetailUnit> allUnits = paperDetailUnitRepo.findByQuestionIn(quesList);
             for (PaperDetailUnit pdu : allUnits) {
                 if (pdu.getPaper() != null && pdu.getPaper().getPaperType() == PaperType.GENERATE) {
-                    msg = "待删除试卷中有试题被组卷使用,不能删除!";
-                    msgMap.put("msg", msg);
-                    msgMap.put("paperName", pdu.getPaper().getName());
-                    return msgMap;
+//                    msg = "待删除试卷中有试题被组卷使用,不能删除!";
+//                    msgMap.put("msg", msg);
+//                    msgMap.put("paperName", pdu.getPaper().getName());
+//                    return msgMap;
+                    throw new StatusException("试卷["+pdu.getPaper().getName()+"]中有试题被组卷使用,不能删除");
                 }
             }
             //删除音频
@@ -555,7 +598,7 @@ public class PaperServiceImpl implements PaperService {
             quesRepo.deleteAll(quesList);
         } else if (papers.get(0).getPaperType() == PaperType.GENERATE) {
             for (Paper paper : papers) {
-                List<String> examPaperIds = extractConfigService.getExamPaperId(paper.getCourseNo(), paper.getOrgId());
+//                List<String> examPaperIds = extractConfigService.getExamPaperId(paper.getCourseNo(), paper.getOrgId());
 //                if (examPaperIds != null && examPaperIds.contains(paper.getId())) {
 //                    msg = "待删除试卷有被调卷规则使用,不能删除!";
 //                    msgMap.put("msg", msg);
@@ -563,10 +606,7 @@ public class PaperServiceImpl implements PaperService {
 //                    return msgMap;
 //                }
                 if(paper.getInUse()!=null&&paper.getInUse()==1) {
-					msg = "待删除试卷已调用,不能删除!";
-		            msgMap.put("msg", msg);
-		            msgMap.put("paperName", paper.getName());
-		            return msgMap;
+		            throw new StatusException("试卷["+paper.getName()+"]已调用,不能删除");
         		}
             }
         }
@@ -589,9 +629,6 @@ public class PaperServiceImpl implements PaperService {
 
             }
         }
-        msg = "success";
-        msgMap.put("msg", msg);
-        return msgMap;
     }
 
     /**