소스 검색

修改题库机构分离的bug

宋悦 8 년 전
부모
커밋
c822845cb1

+ 11 - 2
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperStructService.java

@@ -22,6 +22,9 @@ import com.qmth.cqb.utils.CommonUtils;
 
 
 import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
 import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
 
 
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.exact;
+
 /**
 /**
  * Created by songyue on 16/12/28.
  * Created by songyue on 16/12/28.
  */
  */
@@ -43,7 +46,10 @@ public class PaperStructService {
         formatSearchInfo(searchInfo);
         formatSearchInfo(searchInfo);
         PaperStruct paperStruct = BeanCopierUtil.copyProperties(searchInfo, PaperStruct.class);
         PaperStruct paperStruct = BeanCopierUtil.copyProperties(searchInfo, PaperStruct.class);
         formatPaperStruct(paperStruct);
         formatPaperStruct(paperStruct);
-        ExampleMatcher matcher = ExampleMatcher.matching().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING)
+        ExampleMatcher matcher = ExampleMatcher.matching()
+                .withMatcher("name",contains())
+                .withMatcher("creator",contains())
+                .withMatcher("orgId",exact())
                 .withIgnoreNullValues();
                 .withIgnoreNullValues();
         return paperStructRepo.findAll(Example.of(paperStruct, matcher), new PageRequest(curPage - 1, pageSize));
         return paperStructRepo.findAll(Example.of(paperStruct, matcher), new PageRequest(curPage - 1, pageSize));
     }
     }
@@ -57,7 +63,10 @@ public class PaperStructService {
         formatSearchInfo(searchInfo);
         formatSearchInfo(searchInfo);
         PaperStruct paperStruct = BeanCopierUtil.copyProperties(searchInfo, PaperStruct.class);
         PaperStruct paperStruct = BeanCopierUtil.copyProperties(searchInfo, PaperStruct.class);
         formatPaperStruct(paperStruct);
         formatPaperStruct(paperStruct);
-        ExampleMatcher matcher = ExampleMatcher.matching().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING)
+        ExampleMatcher matcher = ExampleMatcher.matching()
+                .withMatcher("name",contains())
+                .withMatcher("creator",contains())
+                .withMatcher("orgId",exact())
                 .withIgnoreNullValues();
                 .withIgnoreNullValues();
         return paperStructRepo.findAll(Example.of(paperStruct, matcher));
         return paperStructRepo.findAll(Example.of(paperStruct, matcher));
     }
     }

+ 2 - 2
cqb-question-resource/src/main/java/com/qmth/cqb/question/dao/QuesRepo.java

@@ -14,8 +14,8 @@ import java.util.Set;
  */
  */
 public interface QuesRepo extends MongoRepository<Question, String>, QueryByExampleExecutor<Question> {
 public interface QuesRepo extends MongoRepository<Question, String>, QueryByExampleExecutor<Question> {
 
 
-    Page<Question> findByIdNotInAndCourseNoAndOrgId(Set<String> idSet, String courseNo, Long orgId,Pageable page);
+    Page<Question> findByIdNotInAndCourseNoAndOrgId(Set<String> idSet, String courseNo, String orgId,Pageable page);
 
 
     Page<Question> findByIdNotInAndCourseNoAndQuestionTypeAndOrgId(Set<String> idSet, String courseNo,
     Page<Question> findByIdNotInAndCourseNoAndQuestionTypeAndOrgId(Set<String> idSet, String courseNo,
-                                                                   QuesStructType quesType, Long orgId,Pageable page);
+                                                                   QuesStructType quesType, String orgId,Pageable page);
 }
 }

+ 2 - 2
cqb-question-resource/src/main/java/com/qmth/cqb/question/service/QuesService.java

@@ -213,8 +213,8 @@ public class QuesService {
                                           Long orgId) {
                                           Long orgId) {
         Pageable page = new PageRequest(curPage - 1, pageSize);
         Pageable page = new PageRequest(curPage - 1, pageSize);
         Page<Question> list = quesType != null
         Page<Question> list = quesType != null
-                ? quesRepo.findByIdNotInAndCourseNoAndQuestionTypeAndOrgId(idSet, courseNo, quesType, orgId,page)
-                : quesRepo.findByIdNotInAndCourseNoAndOrgId(idSet, courseNo,orgId,page);
+                ? quesRepo.findByIdNotInAndCourseNoAndQuestionTypeAndOrgId(idSet, courseNo, quesType, orgId.toString(),page)
+                : quesRepo.findByIdNotInAndCourseNoAndOrgId(idSet, courseNo,orgId.toString(),page);
         for (Question question : list) {
         for (Question question : list) {
             formatQues(question);
             formatQues(question);
         }
         }