From c93bdeb8ed528d015865f763dfc240cbad7aa00b Mon Sep 17 00:00:00 2001 From: 龚焕茏 <2842157468@qq.com> Date: 星期三, 05 六月 2024 11:45:08 +0800 Subject: [PATCH] feat:题目表移除分数字段 --- src/main/java/com/ycl/jxkg/service/impl/QuestionServiceImpl.java | 39 +++++++++++++-------------------------- 1 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/ycl/jxkg/service/impl/QuestionServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/QuestionServiceImpl.java index 64c590d..3f3d40f 100644 --- a/src/main/java/com/ycl/jxkg/service/impl/QuestionServiceImpl.java +++ b/src/main/java/com/ycl/jxkg/service/impl/QuestionServiceImpl.java @@ -1,13 +1,13 @@ package com.ycl.jxkg.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ycl.jxkg.domain.enums.general.StatusEnum; import com.ycl.jxkg.domain.other.KeyValue; import com.ycl.jxkg.domain.entity.Question; -import com.ycl.jxkg.domain.entity.TextContent; -import com.ycl.jxkg.domain.enums.QuestionStatusEnum; import com.ycl.jxkg.domain.enums.QuestionTypeEnum; import com.ycl.jxkg.domain.question.QuestionItemObject; import com.ycl.jxkg.domain.question.QuestionObject; +import com.ycl.jxkg.domain.vo.admin.question.QuestionResponseVO; import com.ycl.jxkg.mapper.QuestionMapper; import com.ycl.jxkg.service.QuestionService; import com.ycl.jxkg.service.SubjectService; @@ -27,6 +27,7 @@ import java.util.Date; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; @Service @@ -39,7 +40,7 @@ @Override - public PageInfo<Question> page(QuestionPageRequestVO requestVM) { + public PageInfo<QuestionResponseVO> page(QuestionPageRequestVO requestVM) { return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() -> questionMapper.page(requestVM) ); @@ -50,24 +51,18 @@ @Transactional public Question insertFullQuestion(QuestionEditRequestVO model, Integer userId) { Date now = new Date(); - Integer gradeLevel = subjectService.levelBySubjectId(model.getSubjectId()); //棰樺共銆佽В鏋愩�侀�夐」绛� 鎻掑叆 - TextContent infoTextContent = new TextContent(); - infoTextContent.setCreateTime(now); - setQuestionInfoFromVM(infoTextContent, model); - textContentService.save(infoTextContent); + String questionObject = setQuestionInfoFromVM(model); Question question = new Question(); question.setSubjectId(model.getSubjectId()); - question.setGradeLevel(gradeLevel); question.setCreateTime(now); question.setQuestionType(model.getQuestionType()); - question.setStatus(QuestionStatusEnum.OK.getCode()); + question.setStatus(StatusEnum.ENABLE); question.setCorrectFromVM(model.getCorrect(), model.getCorrectArray()); - question.setScore(ExamUtil.scoreFromVM(model.getScore())); question.setDifficult(model.getDifficult()); - question.setInfoTextContentId(infoTextContent.getId()); + question.setContent(questionObject); question.setCreateUser(userId); questionMapper.insert(question); return question; @@ -76,20 +71,14 @@ @Override @Transactional public Question updateFullQuestion(QuestionEditRequestVO model) { - Integer gradeLevel = subjectService.levelBySubjectId(model.getSubjectId()); Question question = questionMapper.selectById(model.getId()); question.setSubjectId(model.getSubjectId()); - question.setGradeLevel(gradeLevel); - question.setScore(ExamUtil.scoreFromVM(model.getScore())); question.setDifficult(model.getDifficult()); question.setCorrectFromVM(model.getCorrect(), model.getCorrectArray()); - questionMapper.updateById(question); - //棰樺共銆佽В鏋愩�侀�夐」绛� 鏇存柊 - TextContent infoTextContent = textContentService.getById(question.getInfoTextContentId()); - setQuestionInfoFromVM(infoTextContent, model); - textContentService.updateById(infoTextContent); - + String questionObject = setQuestionInfoFromVM(model); + question.setContent(questionObject); + questionMapper.updateById(question); return question; } @@ -103,8 +92,7 @@ @Override public QuestionEditRequestVO getQuestionEditRequestVM(Question question) { //棰樼洰鏄犲皠 - TextContent questionInfoTextContent = textContentService.getById(question.getInfoTextContentId()); - QuestionObject questionObject = JsonUtil.toJsonObject(questionInfoTextContent.getContent(), QuestionObject.class); + QuestionObject questionObject = JsonUtil.toJsonObject(question.getContent(), QuestionObject.class); QuestionEditRequestVO questionEditRequestVO = new QuestionEditRequestVO(); BeanUtils.copyProperties(question, questionEditRequestVO); questionEditRequestVO.setTitle(questionObject.getTitleContent()); @@ -129,7 +117,6 @@ default: break; } - questionEditRequestVO.setScore(ExamUtil.scoreToVM(question.getScore())); questionEditRequestVO.setAnalyze(questionObject.getAnalyze()); @@ -146,7 +133,7 @@ return questionEditRequestVO; } - public void setQuestionInfoFromVM(TextContent infoTextContent, QuestionEditRequestVO model) { + public String setQuestionInfoFromVM(QuestionEditRequestVO model) { List<QuestionItemObject> itemObjects = model.getItems().stream().map(i -> { QuestionItemObject item = new QuestionItemObject(); @@ -162,7 +149,7 @@ questionObject.setAnalyze(model.getAnalyze()); questionObject.setTitleContent(model.getTitle()); questionObject.setCorrect(model.getCorrect()); - infoTextContent.setContent(JsonUtil.toJsonStr(questionObject)); + return JsonUtil.toJsonStr(questionObject); } @Override -- Gitblit v1.8.0