Browse Source

k12接口提交

weiwenhai 6 years ago
parent
commit
379b52a96e

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

@@ -78,7 +78,7 @@ public class DefaultQuesionController extends ControllerSupport {
 		if(rootOrgId == null){
 			throw new StatusException("Q-011079", "rootOrgId is null");
 		}
-		Page<DefaultQuestion> defaultQuestions = questionProviderService.findQustions(rootOrgId,req.getProperties(),req.getQuestionType(),req.getCurPage(),req.getPageSize());
+		Page<DefaultQuestion> defaultQuestions = questionProviderService.findQustions(rootOrgId,req.getProperties(),req.getCurPage(),req.getPageSize());
 		return new ResponseEntity<Object>(defaultQuestions,HttpStatus.OK);
 	}
 }

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

@@ -79,7 +79,7 @@ public class QuestionCloudServiceProvider implements QuestionCloudService{
 		if(rootOrgId == null){
 			throw new StatusException("Q-011058", "rootOrgId is null");
 		}
-		Page<DefaultQuestion> defaultQuestions = questionProviderService.findQustions(rootOrgId,req.getProperties(),req.getQuestionType(),req.getCurPage(),req.getPageSize());
+		Page<DefaultQuestion> defaultQuestions = questionProviderService.findQustions(rootOrgId,req.getProperties(),req.getCurPage(),req.getPageSize());
 		GetDefaultQuestionsResp resp = new GetDefaultQuestionsResp();
 		resp.setDefaultQuestions(defaultQuestions);
 		return resp;

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

@@ -29,7 +29,7 @@ public interface QuestionProviderService {
 	 * @param map
 	 * @return
 	 */
-	public Page<DefaultQuestion> findQustions(Long rootOrgId,Map<String, String> map,QuestionType questionType,int curPage,int pageSize);
+	public Page<DefaultQuestion> findQustions(Long rootOrgId,Map<String, String> map,int curPage,int pageSize);
 	
 	/**
 	 * 批量保存试题对象

+ 24 - 17
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/QuestionProviderServiceImpl.java

@@ -215,28 +215,35 @@ public class QuestionProviderServiceImpl implements QuestionProviderService{
 	}
 
 	@Override
-	public Page<DefaultQuestion> findQustions(Long rootOrgId,Map<String, String> map,QuestionType questionType,int curPage,int pageSize) {
+	public Page<DefaultQuestion> findQustions(Long rootOrgId,Map<String, String> map,int curPage,int pageSize) {
 		Query query = new Query();
 		query.addCriteria(Criteria.where("orgId").is(rootOrgId.toString()));
 		query.addCriteria(Criteria.where("isolated").is(true));
-		if(questionType == QuestionType.SINGLE_CHOICE){
-			query.addCriteria(Criteria.where("questionType").is(QuesStructType.SINGLE_ANSWER_QUESTION));
-		}else if (questionType == QuestionType.MULTIPLE_CHOICE) {
-			query.addCriteria(Criteria.where("questionType").is(QuesStructType.MULTIPLE_ANSWER_QUESTION));
-		}else if (questionType == QuestionType.ESSAY) {
-			query.addCriteria(Criteria.where("questionType").is(QuesStructType.TEXT_ANSWER_QUESTION));
-		}else if (questionType == QuestionType.FILL_UP) {
-			query.addCriteria(Criteria.where("questionType").is(QuesStructType.FILL_BLANK_QUESTION));
-		}else if (questionType == QuestionType.TRUE_OR_FALSE) {
-			query.addCriteria(Criteria.where("questionType").is(QuesStructType.BOOL_ANSWER_QUESTION));
-		}
 		if(map != null && map.size()>0){
 			for(Map.Entry<String, String> entry:map.entrySet()){
-				 String la = entry.getValue();
-				 la = la.replaceAll(",", "*");
-				 Pattern pattern=Pattern.compile(la, Pattern.CASE_INSENSITIVE);
-				 String key = "properties." + entry.getKey();
-				 query.addCriteria(Criteria.where(key).regex(pattern));
+				if(entry.getKey().equals("questionType")){
+					if(!StringUtils.isBlank(entry.getValue())){
+						if(entry.getValue().equals(QuestionType.SINGLE_CHOICE.toString())){
+							query.addCriteria(Criteria.where("questionType").is(QuesStructType.SINGLE_ANSWER_QUESTION));
+						}else if (entry.getValue().equals(QuestionType.MULTIPLE_CHOICE.toString())) {
+							query.addCriteria(Criteria.where("questionType").is(QuesStructType.MULTIPLE_ANSWER_QUESTION));
+						}else if (entry.getValue().equals(QuestionType.ESSAY.toString())) {
+							query.addCriteria(Criteria.where("questionType").is(QuesStructType.TEXT_ANSWER_QUESTION));
+						}else if (entry.getValue().equals(QuestionType.FILL_UP.toString())) {
+							query.addCriteria(Criteria.where("questionType").is(QuesStructType.FILL_BLANK_QUESTION));
+						}else if (entry.getValue().equals(QuestionType.TRUE_OR_FALSE.toString())) {
+							query.addCriteria(Criteria.where("questionType").is(QuesStructType.BOOL_ANSWER_QUESTION));
+						}else {
+							throw new StatusException("Q-", "题型格式不对!");
+						}
+					}
+				}else {
+					String la = entry.getValue();
+					la = la.replaceAll(",", "*");
+					Pattern pattern=Pattern.compile(la, Pattern.CASE_INSENSITIVE);
+					String key = "properties." + entry.getKey();
+					query.addCriteria(Criteria.where(key).regex(pattern));
+				}
 			 }
 		}
 		long count = this.mongoTemplate.count(query, Question.class);