Просмотр исходного кода

下载试卷传参修改为orgid

xiatian 5 лет назад
Родитель
Сommit
e93986d14b

+ 7 - 7
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/controller/ExportPaperController.java

@@ -50,16 +50,16 @@ public class ExportPaperController extends ControllerSupport {
      * @return
      */
     @ApiOperation(value = "导出试卷", notes = "导出试卷")
-    @GetMapping(value = "/paper/export/{id}/{exportContentList}/{orgName}/{loginName}/{examType}")
+    @GetMapping(value = "/paper/export/{id}/{exportContentList}/{orgId}/{loginName}/{examType}")
     public void getPaperById(HttpServletRequest request, HttpServletResponse response, @PathVariable String id,
-            @PathVariable String orgName, @PathVariable String exportContentList, @PathVariable String loginName,
+            @PathVariable String orgId, @PathVariable String exportContentList, @PathVariable String loginName,
             @PathVariable String examType) {
         log.info("导出开始");
         String psw = request.getParameter("psw");
-        ExportServiceManage esm = exportServiceManageRepo.findByOrgName(orgName);
+        ExportServiceManage esm = exportServiceManageRepo.findByOrgId(orgId);
 
         if (esm == null) {
-            throw new StatusException("500", String.format("学校【%s】尚未配置导出功能!", orgName));
+            throw new StatusException("500", "尚未配置导出功能!");
         }
         User user = getAccessUser();
         exportPaperService.exportPaperFile(id, esm.getExportServiceName(), exportContentList, response, loginName,
@@ -80,14 +80,14 @@ public class ExportPaperController extends ControllerSupport {
     @ApiOperation(value = "批量导出试卷", notes = "批量导出")
     @GetMapping(value = "/paper/batch_export/{paperIds}/{exportContentList}/{orgName}/{loginName}/{examType}")
     public void getPaperByIds(HttpServletRequest request, HttpServletResponse response, @PathVariable String paperIds,
-            @PathVariable String orgName, @PathVariable String exportContentList, @PathVariable String loginName,
+            @PathVariable String orgId, @PathVariable String exportContentList, @PathVariable String loginName,
             @PathVariable String examType) {
         log.info("批量导出");
         List<String> paperList = Stream.of(paperIds.split(",")).collect(Collectors.toList());
-        ExportServiceManage esm = exportServiceManageRepo.findByOrgName(orgName);
+        ExportServiceManage esm = exportServiceManageRepo.findByOrgId(orgId);
 
         if (esm == null) {
-            throw new StatusException("500", String.format("学校【%s】尚未配置导出功能!", orgName));
+            throw new StatusException("500", "尚未配置导出功能!");
         }
 
         try {

+ 6 - 6
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/controller/ExtractConfigController.java

@@ -176,10 +176,10 @@ public class ExtractConfigController extends ControllerSupport {
 
     @Naked
     @ApiOperation(value = "导出单张考试试卷、答案、试卷结构", notes = "导出单张考试试卷、答案、试卷结构")
-    @GetMapping(value = "/exportSingleExamPaperInfo/{orgName}/{exportWay}/{examId}/{courseId}/{exportContentList}/{loginName}")
+    @GetMapping(value = "/exportSingleExamPaperInfo/{orgId}/{exportWay}/{examId}/{courseId}/{exportContentList}/{loginName}")
     public void exportSingleExamPaperInfo(HttpServletResponse response,
                                           @PathVariable String exportWay,
-                                          @PathVariable String orgName,
+                                          @PathVariable String orgId,
                                           @PathVariable String examId,
                                           @PathVariable String courseId,
                                           @PathVariable String exportContentList,
@@ -196,7 +196,7 @@ public class ExtractConfigController extends ControllerSupport {
         }
         exportModel.setExportContentList(list);
         try {
-            extractConfigFileService.exportExamPaperInfo(exportModel, response, loginName, orgName, psw);
+            extractConfigFileService.exportExamPaperInfo(exportModel, response, loginName, orgId, psw);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
@@ -221,10 +221,10 @@ public class ExtractConfigController extends ControllerSupport {
 
     @Naked
     @ApiOperation(value = "导出整个考试下所有 课程的试卷、答案、试卷结构", notes = "导出整个考试下所有 课程的试卷、答案、试卷结构")
-    @GetMapping(value = "/exportBatchExamPaperInfo/{orgName}/{exportWay}/{examId}/{exportContentList}/{loginName}")
+    @GetMapping(value = "/exportBatchExamPaperInfo/{orgId}/{exportWay}/{examId}/{exportContentList}/{loginName}")
     public void exportBatchExamPaperInfo(HttpServletResponse response,
                                          @PathVariable String exportWay,
-                                         @PathVariable String orgName,
+                                         @PathVariable String orgId,
                                          @PathVariable String examId,
                                          @PathVariable String exportContentList,
                                          @PathVariable String loginName) {
@@ -238,7 +238,7 @@ public class ExtractConfigController extends ControllerSupport {
         }
         exportModel.setExportContentList(list);
         try {
-            extractConfigFileService.exportExamPaperInfo(exportModel, response, loginName, orgName, null);
+            extractConfigFileService.exportExamPaperInfo(exportModel, response, loginName, orgId, null);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }

+ 1 - 1
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/ExportServiceManageRepo.java

@@ -5,7 +5,7 @@ import org.springframework.data.mongodb.repository.MongoRepository;
 import org.springframework.data.repository.query.QueryByExampleExecutor;
 
 public interface ExportServiceManageRepo extends MongoRepository<ExportServiceManage, Long>, QueryByExampleExecutor<ExportServiceManage> {
-    ExportServiceManage findByOrgName(String orgName);
+//    ExportServiceManage findByOrgName(String orgName);
 
     ExportServiceManage findByOrgId(String orgId);
 }

+ 8 - 8
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExtractConfigFileServiceImpl.java

@@ -165,7 +165,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
      * @throws Exception
      */
     private void uploadPaperFile(ExtractConfig extractConfig, String paperId, ExportStructure exportStructure, User user, ExamPaper examPaper) throws Exception {
-        ExportServiceManage esm = exportServiceManageRepo.findByOrgName(user.getRootOrgName());
+        ExportServiceManage esm = exportServiceManageRepo.findByOrgId(String.valueOf(user.getRootOrgId()));
         if (esm == null) {
             throw new StatusException("500", "尚未配置导出功能!");
         }
@@ -188,7 +188,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
     }
 
     @Override
-    public void exportExamPaperInfo(ExportPaperInfoModel exportModel, HttpServletResponse response, String loginName, String orgName, String psw) throws Exception {
+    public void exportExamPaperInfo(ExportPaperInfoModel exportModel, HttpServletResponse response, String loginName, String orgId, String psw) throws Exception {
         String tempDir = loginName + System.currentTimeMillis();
         String downloadDir = sysProperty.getDownloadDirectory() + "/" + tempDir;
         String downZipDir = sysProperty.getZipDirectory() + "/" + tempDir;
@@ -252,7 +252,7 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
                             String groupCode = examPaper.getGroupCode();
                             String paperId = examPaper.getPaper().getId();
                             if (groupCode.equals(examFile.getGroupCode())) {
-                                downloadAudio(paperId, examFile, downloadDir, orgName);
+                                downloadAudio(paperId, examFile, downloadDir, orgId);
                             }
 
                         }
@@ -287,11 +287,11 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
      *
      * @throws Exception
      */
-    private void downloadAudio(String paperId, ExamFile examFile, String downloadDir, String orgName) throws Exception {
+    private void downloadAudio(String paperId, ExamFile examFile, String downloadDir, String orgId) throws Exception {
         //Paper paper = paperRepo.findOne(paperId);
-        ExportServiceManage esm = exportServiceManageRepo.findByOrgName(orgName);
+        ExportServiceManage esm = exportServiceManageRepo.findByOrgId(orgId);
         if (esm == null) {
-            esm = exportServiceManageRepo.findByOrgName("陕西师范大学");
+            throw new StatusException("500", "尚未配置导出功能!");
         }
         ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(esm.getExportServiceName());
         PaperExp paperExp = exportPaperAbstractService.initPaperExp(paperId);
@@ -504,9 +504,9 @@ public class ExtractConfigFileServiceImpl implements ExtractConfigFileService {
         //主观题集合
         List<SubjectiveQuestionStructure> subjectiveQuestionStructureList = new ArrayList<>();
 
-        ExportServiceManage esm = exportServiceManageRepo.findByOrgName(exportStructure.getOrgName());
+        ExportServiceManage esm = exportServiceManageRepo.findByOrgId(exportStructure.getOrgId());
         if (esm == null) {
-            esm = exportServiceManageRepo.findByOrgName("陕西师范大学");
+            throw new StatusException("500", "尚未配置导出功能!");
         }
         ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(esm.getExportServiceName());
         Set<Entry<String, String>> entrySet = paperIds.entrySet();

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

@@ -72,7 +72,6 @@ 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.ExportServiceManage;
 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;
@@ -1450,8 +1449,7 @@ public class PaperServiceImpl implements PaperService {
     @Override
     public String findQuestionStructure(String paperId) throws Exception {
         //根据paperId查询新的对象
-        ExportServiceManage esm = exportServiceManageRepo.findByOrgName("陕西师范大学");
-        ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(esm.getExportServiceName());
+        ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById("sxsfExportPaperService");
         PaperExp paperExp = exportPaperAbstractService.initPaperExp(paperId);
         log.info("已经获取试卷");
         //得到试卷中的客观大题