|
|
@@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -150,17 +151,18 @@ public class QuestionServiceImpl implements QuestionService {
|
|
|
@Transactional(readOnly = true)
|
|
|
@Override
|
|
|
public Page<BaseQuestionVO> getCreatedQuestions(LoginUser user, String stem, String tag, String knowledgeId, Pageable pageable) {
|
|
|
- Page<String> questionIdPage = questionRecordDAO.findQuestionIdsByTeacher(userDAO.findUserById(user.getId()), pageable);
|
|
|
-// List<String> knowledgeIdList = (knowledgeId==null || knowledgeId.equals("")) ? new ArrayList<>() : Arrays.asList(knowledgeId.split("\\."));
|
|
|
+ List<String> questionIds = questionRecordDAO.findQuestionIdsByTeacher(userDAO.findUserById(user.getId()), pageable.getSort());
|
|
|
// 目前仅支持单个知识点的匹配 多个知识点匹配仍需进一步完善
|
|
|
// 这里对当前用户创建的所有问题 根据题干语句、知识点 进行筛选
|
|
|
- List<BaseQuestionVO> ret = questionQueryApi.getQuestionListById(questionIdPage.getContent())
|
|
|
+ List<BaseQuestionVO> matchedQuestions = questionQueryApi.getQuestionListById(questionIds)
|
|
|
.stream()
|
|
|
.filter(questionVO -> questionVO.getStem().contains(stem) &&
|
|
|
questionVO.getKnowledgeId().stream().anyMatch(singleKnowledge -> singleKnowledge.contains(knowledgeId)))
|
|
|
.map(bokQuestion -> BaseQuestionVO.convertBokQuestionToVO(bokQuestion, true))
|
|
|
.collect(Collectors.toList());
|
|
|
- return new PageImpl<>(ret, pageable, ret.size());
|
|
|
+ int fromIndex = pageable.getPageNumber()*pageable.getPageSize();
|
|
|
+ int toIndex = Math.min((fromIndex+pageable.getPageSize()), matchedQuestions.size());
|
|
|
+ return new PageImpl<>(matchedQuestions.subList(fromIndex, toIndex), pageable, matchedQuestions.size());
|
|
|
}
|
|
|
|
|
|
// @Transactional(readOnly = true)
|
|
|
@@ -180,8 +182,8 @@ public class QuestionServiceImpl implements QuestionService {
|
|
|
|
|
|
@Transactional(readOnly = true)
|
|
|
@Override
|
|
|
- public Set<String> getIdsOfCreatedQuestions(LoginUser user) {
|
|
|
- return questionRecordDAO.findQuestionIdsByTeacher(userDAO.findUserById(user.getId()));
|
|
|
+ public List<String> getIdsOfCreatedQuestions(LoginUser user) {
|
|
|
+ return questionRecordDAO.findQuestionIdsByTeacher(userDAO.findUserById(user.getId()), (Sort) null);
|
|
|
}
|
|
|
|
|
|
@Override
|