|
@@ -1,27 +1,152 @@
|
|
package com.qmth.cqb.paper.service;
|
|
package com.qmth.cqb.paper.service;
|
|
|
|
|
|
-import com.qmth.cqb.genpaper.dao.GenPaperRepo;
|
|
|
|
-import com.qmth.cqb.genpaper.service.GenPaperService;
|
|
|
|
-import com.qmth.cqb.question.dao.ImportPaperRepo;
|
|
|
|
-import com.qmth.cqb.question.model.ImportPaper;
|
|
|
|
-import com.qmth.cqb.question.service.ImportPaperService;
|
|
|
|
|
|
+import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashSet;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Set;
|
|
|
|
+
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.domain.Example;
|
|
|
|
+import org.springframework.data.domain.ExampleMatcher;
|
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import com.qmth.cqb.paper.dao.ExamPaperRepo;
|
|
|
|
+import com.qmth.cqb.paper.dao.PaperRepo;
|
|
|
|
+import com.qmth.cqb.paper.model.ExamPaper;
|
|
|
|
+import com.qmth.cqb.paper.model.Paper;
|
|
|
|
+import com.qmth.cqb.paper.model.PaperDetail;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Created by songyue on 16/12/28.
|
|
* Created by songyue on 16/12/28.
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class PaperService {
|
|
public class PaperService {
|
|
- @Autowired
|
|
|
|
- GenPaperService genPaperService;
|
|
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ PaperRepo paperRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ PaperDetailService paperDetailService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ ExamPaperRepo examPaperRepo;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询考试试卷
|
|
|
|
+ * @param examId
|
|
|
|
+ * @param courseCode
|
|
|
|
+ * @param groupCode
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<Paper> listExamPapers(long examId,String courseCode,String groupCode){
|
|
|
|
+ List<Paper> papers = new ArrayList<Paper>();
|
|
|
|
+ ExamPaper examPaper = new ExamPaper();
|
|
|
|
+ examPaper.setExamId(examId);
|
|
|
|
+ examPaper.setCourseCode(courseCode);
|
|
|
|
+ examPaper.setGroupCode(groupCode);
|
|
|
|
+ List<ExamPaper> examPapers = examPaperRepo.findAll(Example.of(examPaper));
|
|
|
|
+ for(ExamPaper ePaper:examPapers){
|
|
|
|
+ Paper paper = paperRepo.findOne(ePaper.getPaperId());
|
|
|
|
+ papers.add(paper);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return papers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设置考试试卷
|
|
|
|
+ * @param examId
|
|
|
|
+ * @param courseCode
|
|
|
|
+ * @param groupCode
|
|
|
|
+ * @param paperId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public boolean joinToExamPaper(long examId,String courseCode,String groupCode,String paperId){
|
|
|
|
+ boolean flag = false;
|
|
|
|
+ ExamPaper examPaper = new ExamPaper();
|
|
|
|
+ examPaper.setExamId(examId);
|
|
|
|
+ examPaper.setGroupCode(groupCode);
|
|
|
|
+ examPaper.setCourseCode(courseCode);
|
|
|
|
+ examPaper.setPaperId(paperId);
|
|
|
|
+ examPaperRepo.save(examPaper);
|
|
|
|
+ flag = true;
|
|
|
|
+ return flag;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public boolean releaseExamPaper(long examId,String courseCode,String groupCode,String paperId){
|
|
|
|
+ boolean flag = false;
|
|
|
|
+ ExamPaper examPaper = new ExamPaper();
|
|
|
|
+ examPaper.setExamId(examId);
|
|
|
|
+ examPaper.setGroupCode(groupCode);
|
|
|
|
+ examPaper.setCourseCode(courseCode);
|
|
|
|
+ examPaper.setPaperId(paperId);
|
|
|
|
+ examPaperRepo.delete(examPaper);
|
|
|
|
+ flag = true;
|
|
|
|
+ return flag;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public Set<String> listGroupCodes(long examId,String courseCode){
|
|
|
|
+ Set<String> groupSet = new HashSet<String>();
|
|
|
|
+ ExamPaper examPaper = new ExamPaper();
|
|
|
|
+ examPaper.setExamId(examId);
|
|
|
|
+ examPaper.setCourseCode(courseCode);
|
|
|
|
+ List<ExamPaper> examPapers = examPaperRepo.findAll(Example.of(examPaper));
|
|
|
|
+ for(ExamPaper expaper:examPapers){
|
|
|
|
+ groupSet.add(expaper.getGroupCode());
|
|
|
|
+ }
|
|
|
|
+ return groupSet;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public boolean deletGroupCode(long examId,String courseCode,String groupCode){
|
|
|
|
+ boolean flag = false;
|
|
|
|
+ ExamPaper examPaper = new ExamPaper();
|
|
|
|
+ examPaper.setExamId(examId);
|
|
|
|
+ examPaper.setCourseCode(courseCode);
|
|
|
|
+ examPaper.setCourseCode(courseCode);
|
|
|
|
+ examPaperRepo.delete(examPaper);
|
|
|
|
+ flag = true;
|
|
|
|
+ return flag;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据试卷ID获取试卷下面的大题
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<PaperDetail> findPaperDetailsById(String id){
|
|
|
|
+ return paperDetailService.getPaperDetailsByPaper(paperRepo.findOne(id));
|
|
|
|
+ }
|
|
|
|
|
|
- @Autowired
|
|
|
|
- GenPaperRepo genPaperRepo;
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 按ID查询试卷
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Paper findById(String id){
|
|
|
|
+ return paperRepo.findOne(id);
|
|
|
|
+ }
|
|
|
|
|
|
- @Autowired
|
|
|
|
- ImportPaperRepo importPaperRepo;
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 保存试卷
|
|
|
|
+ * @param Paper
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Paper savePaper(Paper pd){
|
|
|
|
+ Paper paper = paperRepo.save(pd);
|
|
|
|
+ return paper;
|
|
|
|
+ }
|
|
|
|
|
|
- @Autowired
|
|
|
|
- ImportPaperService importPaperService;
|
|
|
|
}
|
|
}
|