Browse Source

提交K12代码

weiwenhai 6 years ago
parent
commit
d288dfaa55

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

@@ -4,6 +4,7 @@ import java.util.List;
 
 import io.swagger.annotations.ApiOperation;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -17,9 +18,11 @@ import cn.com.qmth.examcloud.commons.web.security.bean.User;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.questions.api.bean.PaperK12Bean;
 import cn.com.qmth.examcloud.core.questions.api.request.GetDefaultQuesionsReq;
+import cn.com.qmth.examcloud.core.questions.api.request.GetExtractConfigReq;
 import cn.com.qmth.examcloud.core.questions.api.request.GetPaperReq;
 import cn.com.qmth.examcloud.core.questions.api.request.GetQuestionListReq;
 import cn.com.qmth.examcloud.core.questions.api.response.GetPaperResp;
+import cn.com.qmth.examcloud.core.questions.dao.entity.ExtractConfig;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
 import cn.com.qmth.examcloud.core.questions.service.PaperProviderService;
 import cn.com.qmth.examcloud.question.core.paper.DefaultPaper;
@@ -54,11 +57,26 @@ public class DefaultPaperController extends ControllerSupport {
     @PostMapping("/findPaper")
 	public ResponseEntity<Object> findPaper(@RequestBody GetPaperReq req){
 		String paperId  = req.getPaperId();
-		if(null == paperId){
+		if(StringUtils.isBlank(paperId)){
 			throw new StatusException("Q-016057", "paperId is null");
 		}
 		DefaultPaper defaultPaper = paperProviderService.findPaper(paperId);
 		return new ResponseEntity<Object>(defaultPaper,HttpStatus.OK);
 	}
 	
+	@ApiOperation(value = "外部接口查询试卷", notes = "外部接口查询试卷")
+    @PostMapping("/findExamPaper")
+	public ResponseEntity<Object> findExamPaper(@RequestBody GetExtractConfigReq req){
+		String rootOrgId = req.getRootOrgId();
+		if(StringUtils.isBlank(rootOrgId)){
+			throw new StatusException("Q-016068", "rootOrgId is null");
+		}
+		Long examId = req.getExamId();
+		if(null == examId){
+			throw new StatusException("Q-016073", "examId is null");
+		}
+		DefaultPaper defaultPaper = paperProviderService.findExamPaper(rootOrgId,examId);
+		return new ResponseEntity<Object>(defaultPaper,HttpStatus.OK);
+	}
+	
 }

+ 8 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperProviderService.java

@@ -34,4 +34,12 @@ public interface PaperProviderService {
 	 */
 	public String examPaper(String orgId, String paperId, Long examId, String extractConfigId);
 	
+	
+	/**
+	 * 根据考试Id查询试卷对象
+	 * @param examId
+	 * @return
+	 */
+	public DefaultPaper findExamPaper(String orgId, Long examId);
+	
 }

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

@@ -158,6 +158,9 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
 			return null;
 		}
 		Query query = new Query();
+		if(!StringUtils.isBlank(condition.getOrgId())){
+			query.addCriteria(Criteria.where("orgId").is(condition.getOrgId()));
+		}
         query.addCriteria(Criteria.where("examId").is(condition.getExamId()));
         query.addCriteria(Criteria.where("courseCode").is(condition.getCourseCode()));
         ExtractConfig tempConfig = this.mongoTemplate.findOne(query, ExtractConfig.class);

+ 22 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperProviderServiceImpl.java

@@ -237,4 +237,26 @@ public class PaperProviderServiceImpl implements PaperProviderService{
 		}
 	}
 
+	@Override
+	public DefaultPaper findExamPaper(String orgId, Long examId) {
+		ExtractConfig extractConfig = new ExtractConfig();
+		extractConfig.setExamId(examId);
+		extractConfig.setCourseCode("K12");
+		extractConfig.setOrgId(orgId);
+		ExtractConfig tempConfig = extractConfigService.findConfig(extractConfig);
+		if(tempConfig == null){
+    		throw new StatusException("Q-014249", "该场考试没有关联试卷");
+    	}
+		List<ExamPaper> list = tempConfig.getExamPaperList();
+		if(list == null || list.size()<1){
+			throw new StatusException("Q-014252", "该场考试关联试卷集合为空");
+		}
+		String paperId = list.get(0).getId();
+		if(StringUtils.isBlank(paperId)){
+			throw new StatusException("Q-014256", "该场考试关联的试卷id为空");
+		}
+		DefaultPaper defaultPaper = findPaper(paperId);
+		return defaultPaper;
+	}
+
 }