|
|
@@ -1,13 +1,19 @@
|
|
|
package vip.xiaonuo.exam.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.modelmapper.ModelMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import vip.xiaonuo.auth.core.pojo.SaBaseLoginUser;
|
|
|
+import vip.xiaonuo.exam.api.CourseChapterPaperApi;
|
|
|
+import vip.xiaonuo.exam.domain.CourseChapterPaper;
|
|
|
import vip.xiaonuo.exam.domain.ExamPaper;
|
|
|
import vip.xiaonuo.exam.domain.Question;
|
|
|
import vip.xiaonuo.exam.domain.TextContent;
|
|
|
@@ -17,10 +23,7 @@ import vip.xiaonuo.exam.domain.exam.ExamPaperTitleItemObject;
|
|
|
import vip.xiaonuo.exam.domain.other.KeyValue;
|
|
|
import vip.xiaonuo.exam.mapper.ExamPaperMapper;
|
|
|
import vip.xiaonuo.exam.mapper.QuestionMapper;
|
|
|
-import vip.xiaonuo.exam.service.ExamPaperService;
|
|
|
-import vip.xiaonuo.exam.service.QuestionService;
|
|
|
-import vip.xiaonuo.exam.service.SubjectService;
|
|
|
-import vip.xiaonuo.exam.service.TextContentService;
|
|
|
+import vip.xiaonuo.exam.service.*;
|
|
|
import vip.xiaonuo.exam.service.enums.ActionEnum;
|
|
|
import vip.xiaonuo.exam.utility.DateTimeUtil;
|
|
|
import vip.xiaonuo.exam.utility.ExamUtil;
|
|
|
@@ -35,14 +38,14 @@ import vip.xiaonuo.exam.viewmodel.student.dashboard.PaperFilter;
|
|
|
import vip.xiaonuo.exam.viewmodel.student.dashboard.PaperInfo;
|
|
|
import vip.xiaonuo.exam.viewmodel.student.exam.ExamPaperPageVM;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
-
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
-public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaper> implements ExamPaperService {
|
|
|
+public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaper> implements ExamPaperService, CourseChapterPaperApi {
|
|
|
|
|
|
protected final static ModelMapper modelMapper = ModelMapperSingle.Instance();
|
|
|
private final ExamPaperMapper examPaperMapper;
|
|
|
@@ -51,6 +54,9 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaper> implements
|
|
|
private final QuestionService questionService;
|
|
|
private final SubjectService subjectService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CourseChapterPaperService courseChapterPaperService;
|
|
|
+
|
|
|
@Autowired
|
|
|
public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService) {
|
|
|
super(examPaperMapper);
|
|
|
@@ -203,4 +209,36 @@ public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaper> implements
|
|
|
return titleItem;
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询章节试卷(作业) 按章节ID chapterId 查询,按用户ID userId 查询个人记录
|
|
|
+ * @param chapterId 章节ID
|
|
|
+ * @param userId 用户ID
|
|
|
+ * @return List<Map<String, Object>>
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> queryListByChapterId(String chapterId, String userId) {
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ if(chapterId == null || StringUtils.isEmpty(userId)){
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+ CourseChapterPaper param = new CourseChapterPaper();
|
|
|
+ param.setChapterId(chapterId);
|
|
|
+ // 全部的试卷(作业)关联关系
|
|
|
+ List<CourseChapterPaper> courseChapterList = courseChapterPaperService.queryList(param);
|
|
|
+ if(courseChapterList.isEmpty()){
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+ List<String> paperIds = courseChapterList.stream().map(CourseChapterPaper::getPaperId).collect(Collectors.toList());
|
|
|
+ List<ExamPaper> paperList = examPaperMapper.selectByIds(paperIds);
|
|
|
+ resultList = paperList.stream()
|
|
|
+ .map(BeanUtil::beanToMap)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询查询章节试卷(作业)异常:{}", e);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
}
|