Parcourir la source

Merge branch 'dev_v5.0.1' of http://git.qmth.com.cn/examcloud-backend/examcloud-core-questions.git into dev_v5.0.1

xiatian il y a 2 ans
Parent
commit
5f43d227ee

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

@@ -107,7 +107,7 @@ public class ExtractConfigController extends ControllerSupport {
 			if (extractConfig.getPlayTime() == null) {
 				throw new StatusException("请填写音频播放次数");
 			}
-			extractConfigService.saveExtractConfig(extractConfig);
+			extractConfigService.saveExtractConfigForRandomPaper(extractConfig);
 		}
 
 		// 清除缓存

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

@@ -149,6 +149,6 @@ public interface ExtractConfigService {
 
 	List<ExtractConfig> findExtractConfig(Long examId);
 
-	void saveExtractConfig(ExtractConfig extractConfig);
+	void saveExtractConfigForRandomPaper(ExtractConfig extractConfig);
 
 }

+ 15 - 4
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExtractConfigServiceImpl.java

@@ -94,9 +94,9 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 
     @Autowired
     private CourseService courseService;
-    //
-    //    @Autowired
-    //    private SysProperty sysProperty;
+
+    @Autowired
+    private RandomPaperRepo randomPaperRepo;
 
     @Autowired
     private PaperDtoAssembler paperDtoAssembler;
@@ -189,10 +189,21 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
     
     @Transactional
     @Override
-    public void saveExtractConfig(ExtractConfig extractConfig) {
+    public void saveExtractConfigForRandomPaper(ExtractConfig extractConfig) {
         Course course = courseService.getCourse(Long.valueOf(extractConfig.getOrgId()), extractConfig.getCourseCode());
         extractConfig.setCourse(course);
         extractConfig.setCourseName(course.getName());
+
+        RandomPaper query = new RandomPaper();
+        query.setId(extractConfig.getRandomPaperId());
+        query.setCourseId(Long.parseLong(course.getId()));
+        Example<RandomPaper> queryExample = Example.of(query);
+        boolean exists = randomPaperRepo.exists(queryExample);
+        if(!exists){
+            LOG.warn("随机抽题模板选择错误,与当前课程不匹配! courseId:{} randomPaperId:{}", course.getId(), extractConfig.getRandomPaperId());
+            throw new StatusException("500", "随机抽题模板选择错误,与当前课程不匹配!");
+        }
+
 		// 新增,id为空
 		if (StringUtils.isBlank(extractConfig.getId())) {
 			// 先查询