|
@@ -65,32 +65,25 @@ public class PaperService {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(PaperService.class);
|
|
|
|
|
|
- public List<Paper> listPapers(String status) {
|
|
|
+ public List<Paper> listPapers(Long subjectId, Integer status) {
|
|
|
Sort sort = new Sort(Sort.Direction.DESC, "updatetime");
|
|
|
List<Paper> papers = paperRepo.findAll(sort);
|
|
|
- if (!Constants.NOTALEADY.equals(status) && !Constants.ALEADY.equals(status)) {
|
|
|
- return papers;
|
|
|
+ if (subjectId != null) {
|
|
|
+ papers = papers.stream().filter(p -> p.getSubjectId() == subjectId.longValue())
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
+ if (status != null) {
|
|
|
+ papers = papers.stream().filter(p -> p.getStatus() == status.intValue())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ logger.info("papers size is {},subjectId is {},status is {}", papers.size(), subjectId, status);
|
|
|
|
|
|
- logger.info("papers size is {},status is {}", papers.size(), status);
|
|
|
-
|
|
|
- Iterator<Paper> iterator = papers.iterator();
|
|
|
- while (iterator.hasNext()) {
|
|
|
- Paper paper = iterator.next();
|
|
|
+ for (Paper paper : papers) {
|
|
|
Integer questionNum = paper.getQuestionNum();
|
|
|
- List<Question> questions = questionService.listQuestionByPaper(paper);
|
|
|
+// List<Question> questions = questionService.listQuestionByPaper(paper);
|
|
|
List<Section> sections = sectionService.findByPid(paper.getId());
|
|
|
paper.setSections(sections);
|
|
|
- logger.info("paper id is {},questionNum is {},questions size is {},sections size is {}", paper.getId(), questionNum, questions.size(), sections.size());
|
|
|
- if (Constants.ALEADY.equals(status)) {
|
|
|
- if (questions.size() < questionNum) {
|
|
|
- iterator.remove();
|
|
|
- }
|
|
|
- } else if (Constants.NOTALEADY.equals(status)) {
|
|
|
- if (questions.size() >= questionNum) {
|
|
|
- iterator.remove();
|
|
|
- }
|
|
|
- }
|
|
|
+ logger.info("paper id is {},questionNum is {},sections size is {}", paper.getId(), questionNum, sections.size());
|
|
|
}
|
|
|
logger.info("after filter,papers size is {}", papers.size());
|
|
|
return papers;
|
|
@@ -98,7 +91,7 @@ public class PaperService {
|
|
|
|
|
|
public Paper getOnePaper(Long id) {
|
|
|
Paper paper = paperRepo.getOne(id);
|
|
|
- if (paper == null || paper.getStatus() == 0) {
|
|
|
+ if (paper == null || paper.getStatus() == Constants.NOTREADY) {
|
|
|
return null;
|
|
|
}
|
|
|
List<Question> questions = questionRepo.findByPidOrderBySectionAscNumberAsc(id);
|