From d34010bcdba98d6906c3ad0959db3c650ea90239 Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期四, 06 六月 2024 11:19:42 +0800
Subject: [PATCH] feat:科目查询、新增、状态、排序、删除、修改
---
src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java | 97 +++++++++++++++++++++++-------------------------
1 files changed, 47 insertions(+), 50 deletions(-)
diff --git a/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
index 227d86f..f661b55 100644
--- a/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
+++ b/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
@@ -2,7 +2,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.jxkg.domain.entity.TextContent;
-import com.ycl.jxkg.domain.enums.ExamPaperTypeEnum;
+import com.ycl.jxkg.enums.ExamPaperTypeEnum;
import com.ycl.jxkg.domain.exam.ExamPaperQuestionItemObject;
import com.ycl.jxkg.domain.exam.ExamPaperTitleItemObject;
import com.ycl.jxkg.domain.other.KeyValue;
@@ -15,25 +15,21 @@
import com.ycl.jxkg.service.enums.ActionEnum;
import com.ycl.jxkg.utils.DateTimeUtil;
import com.ycl.jxkg.utils.JsonUtil;
-import com.ycl.jxkg.utils.ExamUtil;
import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperEditRequestVO;
import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperPageRequestVO;
import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperTitleItemVO;
-import com.ycl.jxkg.domain.vo.admin.question.QuestionEditRequestVO;
import com.ycl.jxkg.domain.vo.student.dashboard.PaperFilter;
import com.ycl.jxkg.domain.vo.student.dashboard.PaperInfo;
import com.ycl.jxkg.domain.vo.student.exam.ExamPaperPageVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycl.jxkg.domain.entity.ExamPaper;
-import com.ycl.jxkg.domain.entity.Question;
import com.ycl.jxkg.domain.entity.User;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -85,16 +81,16 @@
frameTextContent.setContent(frameTextContentStr);
frameTextContent.setCreateTime(now);
textContentService.save(frameTextContent);
- examPaper.setFrameTextContentId(frameTextContent.getId());
examPaper.setCreateTime(now);
examPaper.setCreateUser(user.getId());
examPaperFromVM(examPaperEditRequestVO, examPaper, titleItemsVM);
examPaperMapper.insert(examPaper);
} else {
examPaper = examPaperMapper.selectById(examPaperEditRequestVO.getId());
- TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId());
- frameTextContent.setContent(frameTextContentStr);
- textContentService.updateById(frameTextContent);
+ //TODO:寰呭畬鎴�
+// TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId());
+// frameTextContent.setContent(frameTextContentStr);
+// textContentService.updateById(frameTextContent);
examPaperFromVM(examPaperEditRequestVO, examPaper, titleItemsVM);
examPaperMapper.updateById(examPaper);
}
@@ -106,32 +102,32 @@
ExamPaper examPaper = examPaperMapper.selectById(id);
ExamPaperEditRequestVO vo = new ExamPaperEditRequestVO();
BeanUtils.copyProperties(examPaper, vo);
- vo.setLevel(examPaper.getGradeLevel());
- TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId());
- List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent.getContent(), ExamPaperTitleItemObject.class);
- List<Integer> questionIds = examPaperTitleItemObjects.stream()
- .flatMap(t -> t.getQuestionItems().stream()
- .map(q -> q.getId()))
- .collect(Collectors.toList());
- List<Question> questions = questionMapper.selectByIds(questionIds);
- List<ExamPaperTitleItemVO> examPaperTitleItemVOS = examPaperTitleItemObjects.stream().map(t -> {
- ExamPaperTitleItemVO tTitleVM = new ExamPaperTitleItemVO();
- BeanUtils.copyProperties(t, tTitleVM);
- List<QuestionEditRequestVO> questionItemsVM = t.getQuestionItems().stream().map(i -> {
- Question question = questions.stream().filter(q -> q.getId().equals(i.getId())).findFirst().get();
- QuestionEditRequestVO questionEditRequestVO = questionService.getQuestionEditRequestVM(question);
- questionEditRequestVO.setItemOrder(i.getItemOrder());
- return questionEditRequestVO;
- }).collect(Collectors.toList());
- tTitleVM.setQuestionItems(questionItemsVM);
- return tTitleVM;
- }).collect(Collectors.toList());
- vo.setTitleItems(examPaperTitleItemVOS);
- vo.setScore(ExamUtil.scoreToVM(examPaper.getScore()));
- if (ExamPaperTypeEnum.TimeLimit == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) {
- List<String> limitDateTime = Arrays.asList(DateTimeUtil.dateFormat(examPaper.getLimitStartTime()), DateTimeUtil.dateFormat(examPaper.getLimitEndTime()));
- vo.setLimitDateTime(limitDateTime);
- }
+ //TODO:寰呭畬鎴�
+// TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId());
+// List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent.getContent(), ExamPaperTitleItemObject.class);
+// List<Integer> questionIds = examPaperTitleItemObjects.stream()
+// .flatMap(t -> t.getQuestionItems().stream()
+// .map(q -> q.getId()))
+// .collect(Collectors.toList());
+// List<Question> questions = questionMapper.selectByIds(questionIds);
+// List<ExamPaperTitleItemVO> examPaperTitleItemVOS = examPaperTitleItemObjects.stream().map(t -> {
+// ExamPaperTitleItemVO tTitleVM = new ExamPaperTitleItemVO();
+// BeanUtils.copyProperties(t, tTitleVM);
+// List<QuestionEditRequestVO> questionItemsVM = t.getQuestionItems().stream().map(i -> {
+// Question question = questions.stream().filter(q -> q.getId().equals(i.getId())).findFirst().get();
+// QuestionEditRequestVO questionEditRequestVO = questionService.getQuestionEditRequestVM(question);
+// questionEditRequestVO.setItemOrder(i.getItemOrder());
+// return questionEditRequestVO;
+// }).collect(Collectors.toList());
+// tTitleVM.setQuestionItems(questionItemsVM);
+// return tTitleVM;
+// }).collect(Collectors.toList());
+// vo.setTitleItems(examPaperTitleItemVOS);
+// vo.setScore(ExamUtil.scoreToVM(examPaper.getScore()));
+// if (ExamPaperTypeEnum.Random == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) {
+// List<String> limitDateTime = Arrays.asList(DateTimeUtil.dateFormat(examPaper.getLimitStartTime()), DateTimeUtil.dateFormat(examPaper.getLimitEndTime()));
+// vo.setLimitDateTime(limitDateTime);
+// }
return vo;
}
@@ -159,21 +155,22 @@
}
private void examPaperFromVM(ExamPaperEditRequestVO examPaperEditRequestVO, ExamPaper examPaper, List<ExamPaperTitleItemVO> titleItemsVM) {
- Integer gradeLevel = subjectService.levelBySubjectId(examPaperEditRequestVO.getSubjectId());
- Integer questionCount = titleItemsVM.stream()
- .mapToInt(t -> t.getQuestionItems().size()).sum();
- Integer score = titleItemsVM.stream().
- flatMapToInt(t -> t.getQuestionItems().stream()
- .mapToInt(q -> ExamUtil.scoreFromVM(q.getScore()))
- ).sum();
- examPaper.setQuestionCount(questionCount);
- examPaper.setScore(score);
- examPaper.setGradeLevel(gradeLevel);
- List<String> dateTimes = examPaperEditRequestVO.getLimitDateTime();
- if (ExamPaperTypeEnum.TimeLimit == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) {
- examPaper.setLimitStartTime(DateTimeUtil.parse(dateTimes.get(0), DateTimeUtil.STANDER_FORMAT));
- examPaper.setLimitEndTime(DateTimeUtil.parse(dateTimes.get(1), DateTimeUtil.STANDER_FORMAT));
- }
+ //TODO:寰呭畬鎴�
+// Integer gradeLevel = subjectService.levelBySubjectId(examPaperEditRequestVO.getSubjectId());
+// Integer questionCount = titleItemsVM.stream()
+// .mapToInt(t -> t.getQuestionItems().size()).sum();
+// Integer score = titleItemsVM.stream().
+// flatMapToInt(t -> t.getQuestionItems().stream()
+// .mapToInt(q -> ExamUtil.scoreFromVM(q.getScore()))
+// ).sum();
+// examPaper.setQuestionCount(questionCount);
+// examPaper.setScore(score);
+// examPaper.setGradeLevel(gradeLevel);
+// List<String> dateTimes = examPaperEditRequestVO.getLimitDateTime();
+// if (ExamPaperTypeEnum.Random == ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) {
+// examPaper.setLimitStartTime(DateTimeUtil.parse(dateTimes.get(0), DateTimeUtil.STANDER_FORMAT));
+// examPaper.setLimitEndTime(DateTimeUtil.parse(dateTimes.get(1), DateTimeUtil.STANDER_FORMAT));
+// }
}
private List<ExamPaperTitleItemObject> frameTextContentFromVM(List<ExamPaperTitleItemVO> titleItems) {
--
Gitblit v1.8.0