Browse Source

查询试卷结构bug修改

weiwenhai 7 năm trước cách đây
mục cha
commit
c74f3e1afc

+ 28 - 3
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperStructService.java

@@ -1,14 +1,17 @@
 package com.qmth.cqb.paper.service;
 
+import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.stream.Collectors;
 
 import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
+
 import com.qmth.cqb.paper.dao.QuesTypeNameRepo;
 import com.qmth.cqb.paper.dto.QuesNameDto;
 import com.qmth.cqb.paper.model.*;
+
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.*;
@@ -23,7 +26,6 @@ import com.qmth.cqb.utils.BeanCopierUtil;
 import com.qmth.cqb.utils.CommonUtils;
 
 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;
 
@@ -51,7 +53,7 @@ public class PaperStructService {
      * @return
      */
     public Page<PaperStruct> getPaperStructs(PaperStructSearchInfo searchInfo, int curPage, int pageSize) {
-        formatSearchInfo(searchInfo);
+        /*formatSearchInfo(searchInfo);
         PaperStruct paperStruct = BeanCopierUtil.copyProperties(searchInfo, PaperStruct.class);
         formatPaperStruct(paperStruct);
         ExampleMatcher matcher = ExampleMatcher.matching()
@@ -59,7 +61,30 @@ public class PaperStructService {
                 .withMatcher("creator",contains())
                 .withMatcher("orgId",exact())
                 .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));*/
+    	
+    	//create by weiwenhai
+    	Query query = new Query();
+        query.addCriteria(Criteria.where("orgId").is(searchInfo.getOrgId()));
+        if(StringUtils.isNotBlank(searchInfo.getName())){
+        	query.addCriteria(Criteria.where("name").regex(".*?\\" +searchInfo.getName() + ".*"));
+        }
+        if(StringUtils.isNotBlank(searchInfo.getCreator())){
+        	query.addCriteria(Criteria.where("creator").regex(".*?\\" +searchInfo.getCreator() + ".*"));
+        }
+        if(StringUtils.isNotBlank(searchInfo.getCourseNo())){
+        	if(!searchInfo.getCourseNo().equals("ALL")){
+        		query.addCriteria(Criteria.where("courseNo").is(searchInfo.getCourseNo()));
+        	}
+        }else{
+        	query.addCriteria(Criteria.where("courseNo").is(""));
+        }
+        long count = this.mongoTemplate.count(query, PaperStruct.class);
+        query.with(new Sort(new Sort.Order(Sort.Direction.DESC,"createTime")));
+        query.limit(pageSize);
+        query.skip((curPage - 1) * pageSize);
+        List<PaperStruct> paperList = this.mongoTemplate.find(query, PaperStruct.class);
+        return new PageImpl<PaperStruct>(paperList, new PageRequest(curPage - 1, pageSize), count);
     }
 
     /**