From 79c0181cb9c1fccf51836374482b0d65dd06775f Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期一, 17 六月 2024 09:20:36 +0800
Subject: [PATCH] 1
---
src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java | 403 +++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 274 insertions(+), 129 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 7776dc5..c2eb800 100644
--- a/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
+++ b/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
@@ -1,74 +1,215 @@
package com.ycl.jxkg.service.impl;
-import com.ycl.jxkg.domain.TextContent;
-import com.ycl.jxkg.domain.enums.ExamPaperTypeEnum;
-import com.ycl.jxkg.domain.exam.ExamPaperQuestionItemObject;
-import com.ycl.jxkg.domain.exam.ExamPaperTitleItemObject;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ycl.jxkg.base.Result;
+import com.ycl.jxkg.base.SystemCode;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.ycl.jxkg.context.WebContext;
+import com.ycl.jxkg.domain.entity.Question;
+import com.ycl.jxkg.domain.exam.PaperFixQuestionDTO;
+import com.ycl.jxkg.domain.exam.PaperQuestion;
+import com.ycl.jxkg.domain.exam.PaperQuestionSettingDTO;
+import com.ycl.jxkg.domain.form.ExamPaperForm;
+import com.ycl.jxkg.domain.question.QuestionItemObject;
+import com.ycl.jxkg.domain.question.RandomQuestionDTO;
+import com.ycl.jxkg.domain.vo.admin.exam.ExamResponseVO;
+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.ycl.jxkg.enums.ExamPaperTypeEnum;
import com.ycl.jxkg.domain.other.KeyValue;
+import com.ycl.jxkg.enums.QuestionTypeEnum;
+import com.ycl.jxkg.enums.VisibilityEnum;
import com.ycl.jxkg.mapper.ExamPaperMapper;
import com.ycl.jxkg.mapper.QuestionMapper;
import com.ycl.jxkg.service.ExamPaperService;
import com.ycl.jxkg.service.QuestionService;
import com.ycl.jxkg.service.SubjectService;
import com.ycl.jxkg.service.TextContentService;
-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.vo.admin.exam.ExamPaperEditRequestVO;
-import com.ycl.jxkg.vo.admin.exam.ExamPaperPageRequestVO;
-import com.ycl.jxkg.vo.admin.exam.ExamPaperTitleItemVO;
-import com.ycl.jxkg.vo.admin.question.QuestionEditRequestVO;
-import com.ycl.jxkg.vo.student.dashboard.PaperFilter;
-import com.ycl.jxkg.vo.student.dashboard.PaperInfo;
-import com.ycl.jxkg.vo.student.exam.ExamPaperPageVO;
+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.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.ExamPaper;
-import com.ycl.jxkg.domain.Question;
-import com.ycl.jxkg.domain.User;
+import com.ycl.jxkg.domain.entity.ExamPaper;
+import com.ycl.jxkg.utils.PageInfoHelper;
+import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
import java.util.stream.Collectors;
@Service
-public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaper> implements ExamPaperService {
+@RequiredArgsConstructor
+public class ExamPaperServiceImpl extends ServiceImpl<ExamPaperMapper, ExamPaper> implements ExamPaperService {
private final ExamPaperMapper examPaperMapper;
private final QuestionMapper questionMapper;
private final TextContentService textContentService;
private final QuestionService questionService;
private final SubjectService subjectService;
-
- @Autowired
- public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService) {
- super(examPaperMapper);
- this.examPaperMapper = examPaperMapper;
- this.questionMapper = questionMapper;
- this.textContentService = textContentService;
- this.questionService = questionService;
- this.subjectService = subjectService;
- }
+ private final WebContext webContext;
@Override
- public PageInfo<ExamPaper> page(ExamPaperPageRequestVO requestVM) {
- return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
+ @Transactional(rollbackFor = Exception.class)
+ public Result addPaper(ExamPaperForm form) {
+ ExamPaper examPaper = ExamPaperForm.getEntityByForm(form, null);
+ examPaper.setScore(new BigDecimal(form.getScore()));
+ //闅忔満璇曞嵎
+ if (ExamPaperTypeEnum.Random.getCode().equals(form.getPaperType())) {
+ examPaper.setContent(JSON.toJSONString(form.getQuestionSetting()));
+ baseMapper.insert(examPaper);
+ return Result.ok();
+ } else if (ExamPaperTypeEnum.Fixed.getCode().equals(form.getPaperType())) {
+ //鍥哄畾璇曞嵎
+ examPaper.setContent(JSON.toJSONString(form.getQuestionTitleList()));
+ baseMapper.insert(examPaper);
+ return Result.ok();
+ } else {
+ //闅忓簭璇曞嵎
+ Integer subjectId = form.getSubjectId();
+ //棰樼洰閰嶇疆
+ List<PaperQuestionSettingDTO> questionSetting = form.getQuestionSetting();
+ //棰樼洰閰嶇疆閲岄厤鐨勮瘯鍗风被鍨�
+ List<Integer> types = questionSetting.stream().map(PaperQuestionSettingDTO::getQuestionType).collect(Collectors.toList());
+ if (CollectionUtils.isEmpty(types)) {
+ return Result.fail(SystemCode.InnerError.getCode(), "璇曞嵎棰樼洰绫诲瀷涓嶈兘涓虹┖");
+ }
+ Map<Integer, List<Integer>> map = questionMapper.selectBySubject(subjectId, types)
+ .stream().collect(Collectors.groupingBy(RandomQuestionDTO::getQuestionType, Collectors.mapping(RandomQuestionDTO::getQuestionId, Collectors.toList())));
+ List<PaperFixQuestionDTO> questionTitleList = new ArrayList<>();
+ // 閬嶅巻map
+ for (Integer questionType : map.keySet()) {
+ //鏁版嵁搴撻噷鐨勮繖涓被鍨嬬殑棰樼洰
+ List<Integer> questionIdList = map.get(questionType);
+ Result InnerError1 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.SingleChoice.getCode());
+ if (InnerError1 != null) return InnerError1;
+ Result InnerError2 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.MultipleChoice.getCode());
+ if (InnerError2 != null) return InnerError2;
+ Result InnerError3 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.TrueFalse.getCode());
+ if (InnerError3 != null) return InnerError3;
+ Result InnerError4 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.GapFilling.getCode());
+ if (InnerError4 != null) return InnerError4;
+ Result InnerError5 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.ShortAnswer.getCode());
+ if (InnerError5 != null) return InnerError5;
+ Result InnerError6 = createQuestion(questionSetting, questionTitleList, questionType, questionIdList,QuestionTypeEnum.Calculate.getCode());
+ if (InnerError6 != null) return InnerError6;
+ }
+ examPaper.setContent(JSON.toJSONString(form.getQuestionTitleList()));
+ baseMapper.insert(examPaper);
+ return Result.ok();
+ }
+ }
+ //鐢熸垚棰樼洰
+ private Result createQuestion(List<PaperQuestionSettingDTO> questionSetting, List<PaperFixQuestionDTO> questionTitleList, Integer questionType, List<Integer> questionIdList , Integer questionEnumCode) {
+ if (questionType.equals(questionEnumCode)) {
+ //寰幆鎵惧埌瀵瑰簲棰樼洰
+ PaperQuestionSettingDTO settingDTO = new PaperQuestionSettingDTO();
+ for (PaperQuestionSettingDTO dto : questionSetting) {
+ if (dto.getQuestionType().equals(questionType)) {
+ settingDTO = dto;
+ }
+ }
+ // 闇�瑕佺敓鎴愮殑棰樼洰鏁伴噺
+ Integer num = settingDTO.getNum();
+ if(num ==0){
+ //棰樼洰閰嶇疆姝ょ被鍨嬫暟閲忎负0锛岃烦杩囷紝涓嶇敓鎴愰鐩��
+ return null;
+ }
+ if (CollectionUtils.isEmpty(questionIdList) || num > questionIdList.size()) {
+ return Result.fail(SystemCode.InnerError.getCode(), "棰樼洰鏁伴噺涓嶈冻");
+ }
+ // 浣跨敤Random绫荤敓鎴愪笉閲嶅鐨勯殢鏈虹储寮�
+ Set<Integer> indexes = new HashSet<>();
+ Random random = new Random();
+ while (indexes.size() < num) {
+ int index = random.nextInt(questionIdList.size());
+ indexes.add(index);
+ }
+ // 鏍规嵁绱㈠紩鑾峰彇棰樼洰
+ List<Integer> questionIds = new ArrayList<>();
+ for (int index : indexes) {
+ questionIds.add(questionIdList.get(index));
+ }
+ QueryWrapper<Question> wrapper = new QueryWrapper<>();
+ wrapper.in("id",questionIds);
+ List<Question> questions = questionMapper.selectList(wrapper);
+ List<PaperQuestion> questionList = new ArrayList<>();
+ for (Question question : questions) {
+ PaperQuestion paperQuestion = new PaperQuestion();
+ BeanUtils.copyProperties(question,paperQuestion);
+ paperQuestion.setScore(settingDTO.getScore());
+ paperQuestion.setItems(JSONArray.parseArray(question.getContent(), QuestionItemObject.class));
+ questionList.add(paperQuestion);
+ }
+ PaperFixQuestionDTO dto = new PaperFixQuestionDTO();
+ dto.setTitle(settingDTO.getTitle());
+ dto.setQuestionType(questionType);
+ dto.setQuestionList(questionList);
+ questionTitleList.add(dto);
+ }
+ return null;
+ }
+
+ @Override
+ public Result updateExamPaper(ExamPaperForm form) {
+ ExamPaper examPaper = ExamPaperForm.getEntityByForm(form, null);
+ examPaper.setScore(new BigDecimal(form.getScore()));
+ //闅忔満璇曞嵎
+ if (ExamPaperTypeEnum.Random.getCode().equals(form.getPaperType())) {
+ examPaper.setContent(JSON.toJSONString(form.getQuestionSetting()));
+ baseMapper.updateById(examPaper);
+ return Result.ok();
+ } else if (ExamPaperTypeEnum.Fixed.getCode().equals(form.getPaperType())) {
+ //鍥哄畾璇曞嵎
+ examPaper.setContent(JSON.toJSONString(form.getQuestionTitleList()));
+ baseMapper.updateById(examPaper);
+ return Result.ok();
+ } else {
+ //闅忓簭璇曞嵎
+ examPaper.setContent(JSON.toJSONString(form.getQuestionTitleList()));
+ baseMapper.updateById(examPaper);
+ return Result.ok();
+ }
+ }
+
+ @Override
+ public PageInfo<ExamResponseVO> page(ExamPaperPageRequestVO requestVM) {
+ PageInfo<ExamPaper> page = PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
examPaperMapper.page(requestVM));
+ PageInfo<ExamResponseVO> pageVO = PageInfoHelper.copyMap(page, e -> {
+ ExamResponseVO vo = new ExamResponseVO();
+ BeanUtils.copyProperties(e, vo);
+ vo.setVisibility(VisibilityEnum.valueOf(vo.getVisibility()).getCode() + "");
+ vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
+ return vo;
+ });
+ return pageVO;
}
- @Override
- public PageInfo<ExamPaper> taskExamPage(ExamPaperPageRequestVO requestVM) {
- return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
- examPaperMapper.taskExamPage(requestVM));
- }
+
+// @Override
+// public PageInfo<ExamPaper> taskExamPage(ExamPaperPageRequestVO requestVM) {
+// return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
+// examPaperMapper.taskExamPage(requestVM));
+// }
@Override
public PageInfo<ExamPaper> studentPage(ExamPaperPageVO requestVM) {
@@ -77,69 +218,52 @@
}
- @Override
- @Transactional
- public ExamPaper savePaperFromVM(ExamPaperEditRequestVO examPaperEditRequestVO, User user) {
- ActionEnum actionEnum = (examPaperEditRequestVO.getId() == null) ? ActionEnum.ADD : ActionEnum.UPDATE;
- Date now = new Date();
- List<ExamPaperTitleItemVO> titleItemsVM = examPaperEditRequestVO.getTitleItems();
- List<ExamPaperTitleItemObject> frameTextContentList = frameTextContentFromVM(titleItemsVM);
- String frameTextContentStr = JsonUtil.toJsonStr(frameTextContentList);
-
- ExamPaper examPaper = new ExamPaper();
- BeanUtils.copyProperties(examPaperEditRequestVO, examPaper);
- if (actionEnum == ActionEnum.ADD) {
- TextContent frameTextContent = new TextContent();
- frameTextContent.setContent(frameTextContentStr);
- frameTextContent.setCreateTime(now);
- textContentService.insertByFilter(frameTextContent);
- examPaper.setFrameTextContentId(frameTextContent.getId());
- examPaper.setCreateTime(now);
- examPaper.setCreateUser(user.getId());
- examPaper.setDeleted(false);
- examPaperFromVM(examPaperEditRequestVO, examPaper, titleItemsVM);
- examPaperMapper.insertSelective(examPaper);
- } else {
- examPaper = examPaperMapper.selectByPrimaryKey(examPaperEditRequestVO.getId());
- TextContent frameTextContent = textContentService.selectById(examPaper.getFrameTextContentId());
- frameTextContent.setContent(frameTextContentStr);
- textContentService.updateByIdFilter(frameTextContent);
- examPaperFromVM(examPaperEditRequestVO, examPaper, titleItemsVM);
- examPaperMapper.updateByPrimaryKeySelective(examPaper);
- }
- return examPaper;
- }
+// @Override
+// @Transactional
+// public ExamPaper savePaperFromVM(ExamPaperEditRequestVO examPaperEditRequestVO, User user) {
+// ActionEnum actionEnum = (examPaperEditRequestVO.getId() == null) ? ActionEnum.ADD : ActionEnum.UPDATE;
+// Date now = new Date();
+// List<ExamPaperTitleItemVO> titleItemsVM = examPaperEditRequestVO.getTitleItems();
+// List<ExamPaperTitleItemObject> frameTextContentList = frameTextContentFromVM(titleItemsVM);
+// String frameTextContentStr = JsonUtil.toJsonStr(frameTextContentList);
+//
+// ExamPaper examPaper = new ExamPaper();
+// BeanUtils.copyProperties(examPaperEditRequestVO, examPaper);
+// if (actionEnum == ActionEnum.ADD) {
+// TextContent frameTextContent = new TextContent();
+// frameTextContent.setContent(frameTextContentStr);
+// frameTextContent.setCreateTime(now);
+// textContentService.save(frameTextContent);
+// examPaper.setCreateTime(now);
+// examPaper.setCreateUser(user.getId());
+// examPaperFromVM(examPaperEditRequestVO, examPaper, titleItemsVM);
+// examPaperMapper.insert(examPaper);
+// } else {
+// examPaper = examPaperMapper.selectById(examPaperEditRequestVO.getId());
+// //TODO:
+// TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId());
+// frameTextContent.setContent(frameTextContentStr);
+// textContentService.updateById(frameTextContent);
+// examPaperFromVM(examPaperEditRequestVO, examPaper, titleItemsVM);
+// examPaperMapper.updateById(examPaper);
+// }
+// return examPaper;
+// }
@Override
public ExamPaperEditRequestVO examPaperToVM(Integer id) {
- ExamPaper examPaper = examPaperMapper.selectByPrimaryKey(id);
+ ExamPaper examPaper = examPaperMapper.selectById(id);
ExamPaperEditRequestVO vo = new ExamPaperEditRequestVO();
BeanUtils.copyProperties(examPaper, vo);
- vo.setLevel(examPaper.getGradeLevel());
- TextContent frameTextContent = textContentService.selectById(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);
+ vo.setVisibility(VisibilityEnum.valueOf(vo.getVisibility()).getCode());
+ //闅忔満璇曞嵎
+ if (ExamPaperTypeEnum.Random.getCode().equals(examPaper.getPaperType())) {
+ vo.setQuestionSetting(JSONArray.parseArray(examPaper.getContent(), PaperQuestionSettingDTO.class));
+ } else if (ExamPaperTypeEnum.Fixed.getCode().equals(examPaper.getPaperType())) {
+ //鍥哄畾璇曞嵎
+ vo.setQuestionTitleList(JSONArray.parseArray(examPaper.getContent(), PaperFixQuestionDTO.class));
+ } else {
+ //闅忓簭璇曞嵎
}
return vo;
}
@@ -167,39 +291,60 @@
}).collect(Collectors.toList());
}
+
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) {
- AtomicInteger index = new AtomicInteger(1);
- return titleItems.stream().map(t -> {
- ExamPaperTitleItemObject titleItem = new ExamPaperTitleItemObject();
- BeanUtils.copyProperties(t, titleItem);
- List<ExamPaperQuestionItemObject> questionItems = t.getQuestionItems().stream()
- .map(q -> {
- ExamPaperQuestionItemObject examPaperQuestionItemObject = new ExamPaperQuestionItemObject();
- BeanUtils.copyProperties(q, examPaperQuestionItemObject);
- examPaperQuestionItemObject.setItemOrder(index.getAndIncrement());
- return examPaperQuestionItemObject;
- })
- .collect(Collectors.toList());
- titleItem.setQuestionItems(questionItems);
- return titleItem;
- }).collect(Collectors.toList());
+// private List<ExamPaperTitleItemObject> frameTextContentFromVM(List<ExamPaperTitleItemVO> titleItems) {
+// AtomicInteger index = new AtomicInteger(1);
+// return titleItems.stream().map(t -> {
+// ExamPaperTitleItemObject titleItem = new ExamPaperTitleItemObject();
+// BeanUtils.copyProperties(t, titleItem);
+// List<ExamPaperQuestionItemObject> questionItems = t.getQuestionItems().stream()
+// .map(q -> {
+// ExamPaperQuestionItemObject examPaperQuestionItemObject = new ExamPaperQuestionItemObject();
+// BeanUtils.copyProperties(q, examPaperQuestionItemObject);
+// examPaperQuestionItemObject.setItemOrder(index.getAndIncrement());
+// return examPaperQuestionItemObject;
+// })
+// .collect(Collectors.toList());
+// titleItem.setQuestionItems(questionItems);
+// return titleItem;
+// }).collect(Collectors.toList());
+// }
+
+ @Override
+ public List<ExamPaper> myExamPaper(Integer paperType) {
+ Integer userId = webContext.getCurrentUser().getId();
+ List<ExamPaper> list = new LambdaQueryChainWrapper<>(baseMapper)
+ .select(ExamPaper::getId, ExamPaper::getName, ExamPaper::getVisibility)
+ .eq(ExamPaper::getCreateUser, userId)
+ .eq(Objects.nonNull(paperType), ExamPaper::getPaperType, paperType)
+ .or()
+ .eq(ExamPaper::getVisibility, VisibilityEnum.Public.getName())
+ .eq(Objects.nonNull(paperType), ExamPaper::getPaperType, paperType)
+ .list();
+ list.stream().forEach(item -> {
+ if (VisibilityEnum.Public.getName().equals(item.getVisibility())) {
+ item.setName(item.getName() + " (鍏紑)");
+ }
+ });
+ return list;
}
}
--
Gitblit v1.8.0