src/main/java/com/ycl/jxkg/controller/admin/ExamPaperController.java
@@ -5,7 +5,9 @@ import com.ycl.jxkg.domain.entity.ExamPaper; import com.ycl.jxkg.domain.entity.ExamPaperQuestion; import com.ycl.jxkg.domain.form.ExamPaperForm; import com.ycl.jxkg.domain.question.TemplateQuestionDTO; import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperQuestionVO; import com.ycl.jxkg.enums.ExamPaperTypeEnum; import com.ycl.jxkg.enums.VisibilityEnum; import com.ycl.jxkg.group.Add; import com.ycl.jxkg.group.Update; @@ -27,6 +29,8 @@ import javax.validation.Valid; import java.util.Date; import java.util.List; @Validated @RequiredArgsConstructor @RestController("AdminExamPaperController") @@ -41,14 +45,7 @@ @RequestMapping(value = "/page", method = RequestMethod.POST) public Result<PageInfo<ExamResponseVO>> pageList(@RequestBody ExamPaperPageRequestVO model) { PageInfo<ExamPaper> pageInfo = examPaperService.page(model); PageInfo<ExamResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> { ExamResponseVO vo = new ExamResponseVO(); BeanUtils.copyProperties(e, vo); vo.setVisibility(VisibilityEnum.valueOf(vo.getVisibility()).getCode()+""); vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); return vo; }); PageInfo<ExamResponseVO> page = examPaperService.page(model); return Result.ok(page); } @@ -60,8 +57,7 @@ } form.setCreateUser(getCurrentUser().getId()); form.setCreateTime(new Date()); ExamPaper entity = ExamPaperForm.getEntityByForm(form,null); examPaperService.save(entity); examPaperService.addPaper(form); return Result.ok(); } @@ -71,9 +67,7 @@ if (!StringUtils.isBlank(form.getVisibility())) { form.setVisibility(VisibilityEnum.fromCode(form.getVisibility()).getName()); } //TODO:修改联表里的分数 ExamPaper entity = ExamPaperForm.getEntityByForm(form,null); examPaperService.updateById(entity); examPaperService.updateExamPaper(form); return Result.ok(); } src/main/java/com/ycl/jxkg/domain/entity/ExamTemplate.java
@@ -21,32 +21,9 @@ private static final long serialVersionUID = 1L; @TableField("name") /** 模板名 */ private String name; @TableField("subject_id") /** 学科id */ private Integer subjectId; @TableField("score") /** 总分 */ private BigDecimal score; @TableField("visibility") /** 是否私有 */ private String visibility; @TableField("suggest_time") /** 建议时间 */ private Integer suggestTime; @TableField("deduct_type") /** 多选扣分类型 */ private Integer deductType; @TableField("deduct_type_score") private BigDecimal deductTypeScore; @TableField("exam_paper_id") /** paperId */ private Integer examPaperId; @TableField("single_choice") /** 单选题数量 */ @@ -92,15 +69,8 @@ /** 简答每题分数 */ private BigDecimal shortAnswerScore; @TableField("calculation__score") @TableField("calculation_score") /** 计算每题分数 */ private BigDecimal calculationScore; @TableField("create_user") /** */ private Integer createUser; @TableField("create_time") /** */ private Date createTime; } src/main/java/com/ycl/jxkg/domain/exam/ExamPaperTempDTO.java
New file @@ -0,0 +1,64 @@ package com.ycl.jxkg.domain.exam; import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.ycl.jxkg.domain.base.AbsEntity; import com.ycl.jxkg.domain.entity.ExamTemplate; import lombok.Data; import java.math.BigDecimal; import java.util.Date; @Data public class ExamPaperTempDTO extends AbsEntity { /** * 试卷名称 */ private String name; /** * 学科 */ private Integer subjectId; /** * 试卷类型( 1固定试卷 2.随即试卷 3.随序试卷) */ private Integer paperType; /** * 试卷总分 */ private BigDecimal score; /** * 题目数量 */ private Integer questionCount; /** * 建议时长(分钟) */ private Integer suggestTime; private Integer createUser; private Date createTime; /** * 可见性,公开/私有 * */ private String visibility; /** * 多选扣分类型 * */ private Integer deductType; /** * 多选评分分数 * */ private BigDecimal deductTypeScore; private ExamTemplate examTemplate; } src/main/java/com/ycl/jxkg/domain/form/ExamPaperForm.java
@@ -7,8 +7,10 @@ import com.ycl.jxkg.domain.base.AbsForm; import com.ycl.jxkg.domain.entity.ExamPaper; import com.ycl.jxkg.domain.entity.ExamTemplate; import com.ycl.jxkg.domain.question.TemplateQuestionDTO; import com.ycl.jxkg.group.Add; import com.ycl.jxkg.group.Update; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.beans.BeanUtils; import org.springframework.lang.NonNull; @@ -18,6 +20,7 @@ import javax.validation.constraints.NotNull; import java.math.BigDecimal; import java.util.Date; import java.util.List; @Data @TableName("t_exam_paper") @@ -77,6 +80,11 @@ * */ private BigDecimal deductTypeScore; /** * 题目模板 * */ private List<TemplateQuestionDTO> questionList; public static ExamPaper getEntityByForm(@NonNull ExamPaperForm form, ExamPaper entity) { if(entity == null) { entity = new ExamPaper(); src/main/java/com/ycl/jxkg/domain/vo/admin/exam/ExamResponseVO.java
@@ -1,10 +1,12 @@ package com.ycl.jxkg.domain.vo.admin.exam; import com.ycl.jxkg.domain.question.TemplateQuestionDTO; import lombok.Data; import java.math.BigDecimal; import java.util.Date; import java.util.List; @Data public class ExamResponseVO { @@ -15,7 +17,7 @@ private Integer questionCount; private Integer score; private BigDecimal score; private String createTime; @@ -32,4 +34,6 @@ private BigDecimal deductTypeScore; private String visibility; private List<TemplateQuestionDTO> questionList; } src/main/java/com/ycl/jxkg/mapper/ExamPaperMapper.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ycl.jxkg.domain.entity.ExamPaper; import com.ycl.jxkg.domain.exam.ExamPaperTempDTO; import com.ycl.jxkg.domain.other.KeyValue; import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperPageRequestVO; import com.ycl.jxkg.domain.vo.student.dashboard.PaperFilter; @@ -16,7 +17,7 @@ @Mapper public interface ExamPaperMapper extends BaseMapper<ExamPaper> { List<ExamPaper> page(ExamPaperPageRequestVO requestVM); List<ExamPaperTempDTO> page(ExamPaperPageRequestVO requestVM); List<ExamPaper> taskExamPage(ExamPaperPageRequestVO requestVM); src/main/java/com/ycl/jxkg/service/ExamPaperService.java
@@ -3,8 +3,10 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ycl.jxkg.domain.entity.ExamPaper; import com.ycl.jxkg.domain.entity.User; import com.ycl.jxkg.domain.form.ExamPaperForm; 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.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; @@ -14,7 +16,7 @@ public interface ExamPaperService extends IService<ExamPaper> { PageInfo<ExamPaper> page(ExamPaperPageRequestVO requestVM); PageInfo<ExamResponseVO> page(ExamPaperPageRequestVO requestVM); PageInfo<ExamPaper> taskExamPage(ExamPaperPageRequestVO requestVM); @@ -29,4 +31,8 @@ Integer selectAllCount(); List<Integer> selectMothCount(); void addPaper(ExamPaperForm form); void updateExamPaper(ExamPaperForm form); } src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
@@ -1,12 +1,21 @@ package com.ycl.jxkg.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.jxkg.domain.entity.ExamTemplate; import com.ycl.jxkg.domain.entity.TextContent; import com.ycl.jxkg.domain.exam.ExamPaperTempDTO; import com.ycl.jxkg.domain.form.ExamPaperForm; import com.ycl.jxkg.domain.question.TemplateQuestionDTO; import com.ycl.jxkg.domain.vo.admin.exam.ExamResponseVO; 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; import com.ycl.jxkg.enums.QuestionTypeEnum; import com.ycl.jxkg.enums.VisibilityEnum; import com.ycl.jxkg.mapper.ExamPaperMapper; import com.ycl.jxkg.mapper.ExamTemplateMapper; import com.ycl.jxkg.mapper.QuestionMapper; import com.ycl.jxkg.service.ExamPaperService; import com.ycl.jxkg.service.QuestionService; @@ -25,11 +34,14 @@ import com.github.pagehelper.PageInfo; import com.ycl.jxkg.domain.entity.ExamPaper; import com.ycl.jxkg.domain.entity.User; import com.ycl.jxkg.utils.PageInfoHelper; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -44,14 +56,119 @@ private final TextContentService textContentService; private final QuestionService questionService; private final SubjectService subjectService; private final ExamTemplateMapper examTemplateMapper; @Override public PageInfo<ExamPaper> page(ExamPaperPageRequestVO requestVM) { return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() -> examPaperMapper.page(requestVM)); @Transactional(rollbackFor = Exception.class) public void addPaper(ExamPaperForm form) { ExamPaper examPaper = ExamPaperForm.getEntityByForm(form,null); baseMapper.insert(examPaper); if(ExamPaperTypeEnum.Random.getCode().equals(form.getPaperType())){ ExamTemplate examTemplate = getExamTemplate(form, examPaper); examTemplateMapper.insert(examTemplate); baseMapper.updateById(examPaper); } //TODO:随序试卷生成题目 } private ExamTemplate getExamTemplate(ExamPaperForm form, ExamPaper examPaper) { //随机试卷存模板 List<TemplateQuestionDTO> questionList = form.getQuestionList(); BigDecimal score = BigDecimal.ZERO; Integer num=0; ExamTemplate examTemplate = new ExamTemplate(); //设置题目信息 for (TemplateQuestionDTO dto : questionList) { num += dto.getNum(); score = score.add(dto.getScore().multiply(BigDecimal.valueOf(dto.getNum()))); Integer questionType = dto.getQuestionType(); //整理List为对象 switch (QuestionTypeEnum.fromCode(questionType)){ //单选 case SingleChoice: examTemplate.setSingleChoice(dto.getNum()); examTemplate.setSingleScore(dto.getScore()); break; //多选 case MultipleChoice: examTemplate.setMultipleChoice(dto.getNum()); examTemplate.setMultipleScore(dto.getScore()); break; //判断 case TrueFalse: examTemplate.setTrueFalse(dto.getNum()); examTemplate.setTrueFalseScore(dto.getScore()); break; //填空 case GapFilling: examTemplate.setGapFilling(dto.getNum()); examTemplate.setGapScore(dto.getScore()); break; //简答 case ShortAnswer: examTemplate.setShortAnswer(dto.getNum()); examTemplate.setShortAnswerScore(dto.getScore()); break; //计算 case Calculation: examTemplate.setCalculation(dto.getNum()); examTemplate.setCalculationScore(dto.getScore()); break; } } examTemplate.setExamPaperId(examPaper.getId()); //回填 examPaper.setQuestionCount(num); examPaper.setScore(score); return examTemplate; } @Override public void updateExamPaper(ExamPaperForm form) { ExamPaper entity = ExamPaperForm.getEntityByForm(form,null); //如果是随机试卷修改template表 if(ExamPaperTypeEnum.Random.getCode().equals(form.getPaperType())){ ExamTemplate examTemplate = getExamTemplate(form, entity); examTemplateMapper.removeById(form.getId()); examTemplateMapper.insert(examTemplate); } baseMapper.updateById(entity); } @Override public PageInfo<ExamResponseVO> page(ExamPaperPageRequestVO requestVM) { PageInfo<ExamPaperTempDTO> 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())); if(ExamPaperTypeEnum.Random.getCode().equals(e.getPaperType())) { //整理题目信息为集合 ExamTemplate examTemplate = e.getExamTemplate(); List<TemplateQuestionDTO> questionList = new ArrayList<>(); addQuestionList(questionList, QuestionTypeEnum.SingleChoice.getCode(), examTemplate.getSingleScore(), examTemplate.getSingleChoice()); addQuestionList(questionList, QuestionTypeEnum.MultipleChoice.getCode(), examTemplate.getMultipleScore(), examTemplate.getMultipleChoice()); addQuestionList(questionList, QuestionTypeEnum.TrueFalse.getCode(), examTemplate.getTrueFalseScore(), examTemplate.getTrueFalse()); addQuestionList(questionList, QuestionTypeEnum.GapFilling.getCode(), examTemplate.getGapScore(), examTemplate.getGapFilling()); addQuestionList(questionList, QuestionTypeEnum.ShortAnswer.getCode(), examTemplate.getShortAnswerScore(), examTemplate.getShortAnswer()); addQuestionList(questionList, QuestionTypeEnum.Calculation.getCode(), examTemplate.getCalculationScore(), examTemplate.getCalculation()); vo.setQuestionList(questionList); } return vo; }); return pageVO; } private void addQuestionList(List<TemplateQuestionDTO> questionList, Integer code,BigDecimal score,Integer num) { TemplateQuestionDTO questionDTO = new TemplateQuestionDTO(); questionDTO.setQuestionType(code); questionDTO.setScore(score); questionDTO.setNum(num); questionList.add(questionDTO); } @Override public PageInfo<ExamPaper> taskExamPage(ExamPaperPageRequestVO requestVM) { return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() -> @@ -87,7 +204,7 @@ examPaperMapper.insert(examPaper); } else { examPaper = examPaperMapper.selectById(examPaperEditRequestVO.getId()); //TODO:待完成 //TODO: // TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId()); // frameTextContent.setContent(frameTextContentStr); // textContentService.updateById(frameTextContent); @@ -102,7 +219,7 @@ ExamPaper examPaper = examPaperMapper.selectById(id); ExamPaperEditRequestVO vo = new ExamPaperEditRequestVO(); BeanUtils.copyProperties(examPaper, vo); //TODO:待完成 //TODO: // TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId()); // List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent.getContent(), ExamPaperTitleItemObject.class); // List<Integer> questionIds = examPaperTitleItemObjects.stream() @@ -154,8 +271,10 @@ }).collect(Collectors.toList()); } private void examPaperFromVM(ExamPaperEditRequestVO examPaperEditRequestVO, ExamPaper examPaper, List<ExamPaperTitleItemVO> titleItemsVM) { //TODO:待完成 //TODO: // Integer gradeLevel = subjectService.levelBySubjectId(examPaperEditRequestVO.getSubjectId()); // Integer questionCount = titleItemsVM.stream() // .mapToInt(t -> t.getQuestionItems().size()).sum(); src/main/java/com/ycl/jxkg/service/impl/ExamTemplateServiceImpl.java
@@ -56,54 +56,54 @@ */ @Override public Result add(ExamTemplateForm form) { ExamTemplate entity = ExamTemplateForm.getEntityByForm(form, null); User currentUser = webContext.getCurrentUser(); entity.setCreateUser(currentUser.getId()); entity.setCreateTime(new Date()); if(!StringUtils.isEmpty(entity.getVisibility())) { entity.setVisibility(VisibilityEnum.fromCode(entity.getVisibility()).getName()); } List<TemplateQuestionDTO> questionList = form.getQuestionList(); BigDecimal score = BigDecimal.ZERO; //设置题目信息 for (TemplateQuestionDTO dto : questionList) { score = score.add(dto.getScore().multiply(BigDecimal.valueOf(dto.getNum()))); Integer questionType = dto.getQuestionType(); switch (QuestionTypeEnum.fromCode(questionType)){ //单选 case SingleChoice: entity.setSingleChoice(dto.getNum()); entity.setSingleScore(dto.getScore()); break; //多选 case MultipleChoice: entity.setMultipleChoice(dto.getNum()); entity.setMultipleScore(dto.getScore()); break; //判断 case TrueFalse: entity.setTrueFalse(dto.getNum()); entity.setTrueFalseScore(dto.getScore()); break; //填空 case GapFilling: entity.setGapFilling(dto.getNum()); entity.setGapScore(dto.getScore()); break; //简答 case ShortAnswer: entity.setShortAnswer(dto.getNum()); entity.setShortAnswerScore(dto.getScore()); break; //计算 case Calculation: entity.setCalculation(dto.getNum()); entity.setCalculationScore(dto.getScore()); break; } } entity.setScore(score); baseMapper.insert(entity); // ExamTemplate entity = ExamTemplateForm.getEntityByForm(form, null); // User currentUser = webContext.getCurrentUser(); // entity.setCreateUser(currentUser.getId()); // entity.setCreateTime(new Date()); // if(!StringUtils.isEmpty(entity.getVisibility())) { // entity.setVisibility(VisibilityEnum.fromCode(entity.getVisibility()).getName()); // } // List<TemplateQuestionDTO> questionList = form.getQuestionList(); // BigDecimal score = BigDecimal.ZERO; // //设置题目信息 // for (TemplateQuestionDTO dto : questionList) { // score = score.add(dto.getScore().multiply(BigDecimal.valueOf(dto.getNum()))); // Integer questionType = dto.getQuestionType(); // switch (QuestionTypeEnum.fromCode(questionType)){ // //单选 // case SingleChoice: // entity.setSingleChoice(dto.getNum()); // entity.setSingleScore(dto.getScore()); // break; // //多选 // case MultipleChoice: // entity.setMultipleChoice(dto.getNum()); // entity.setMultipleScore(dto.getScore()); // break; // //判断 // case TrueFalse: // entity.setTrueFalse(dto.getNum()); // entity.setTrueFalseScore(dto.getScore()); // break; // //填空 // case GapFilling: // entity.setGapFilling(dto.getNum()); // entity.setGapScore(dto.getScore()); // break; // //简答 // case ShortAnswer: // entity.setShortAnswer(dto.getNum()); // entity.setShortAnswerScore(dto.getScore()); // break; // //计算 // case Calculation: // entity.setCalculation(dto.getNum()); // entity.setCalculationScore(dto.getScore()); // break; // } // } // entity.setScore(score); // baseMapper.insert(entity); return Result.ok("添加成功"); } @@ -115,52 +115,52 @@ @Override @Transactional(rollbackFor = Exception.class) public Result update(ExamTemplateForm form) { ExamTemplate entity = ExamTemplateForm.getEntityByForm(form, null); if(!StringUtils.isEmpty(entity.getVisibility())) { entity.setVisibility(VisibilityEnum.fromCode(entity.getVisibility()).getName()); } List<TemplateQuestionDTO> questionList = form.getQuestionList(); BigDecimal score = BigDecimal.ZERO; //设置题目信息 for (TemplateQuestionDTO dto : questionList) { score = score.add(dto.getScore().multiply(BigDecimal.valueOf(dto.getNum()))); Integer questionType = dto.getQuestionType(); switch (QuestionTypeEnum.fromCode(questionType)){ //单选 case SingleChoice: entity.setSingleChoice(dto.getNum()); entity.setSingleScore(dto.getScore()); break; //多选 case MultipleChoice: entity.setMultipleChoice(dto.getNum()); entity.setMultipleScore(dto.getScore()); break; //判断 case TrueFalse: entity.setTrueFalse(dto.getNum()); entity.setTrueFalseScore(dto.getScore()); break; //填空 case GapFilling: entity.setGapFilling(dto.getNum()); entity.setGapScore(dto.getScore()); break; //简答 case ShortAnswer: entity.setShortAnswer(dto.getNum()); entity.setShortAnswerScore(dto.getScore()); break; //计算 case Calculation: entity.setCalculation(dto.getNum()); entity.setCalculationScore(dto.getScore()); break; } } entity.setScore(score); examTemplateMapper.removeById(entity.getId()); baseMapper.insert(entity); // ExamTemplate entity = ExamTemplateForm.getEntityByForm(form, null); // if(!StringUtils.isEmpty(entity.getVisibility())) { // entity.setVisibility(VisibilityEnum.fromCode(entity.getVisibility()).getName()); // } // List<TemplateQuestionDTO> questionList = form.getQuestionList(); // BigDecimal score = BigDecimal.ZERO; // //设置题目信息 // for (TemplateQuestionDTO dto : questionList) { // score = score.add(dto.getScore().multiply(BigDecimal.valueOf(dto.getNum()))); // Integer questionType = dto.getQuestionType(); // switch (QuestionTypeEnum.fromCode(questionType)){ // //单选 // case SingleChoice: // entity.setSingleChoice(dto.getNum()); // entity.setSingleScore(dto.getScore()); // break; // //多选 // case MultipleChoice: // entity.setMultipleChoice(dto.getNum()); // entity.setMultipleScore(dto.getScore()); // break; // //判断 // case TrueFalse: // entity.setTrueFalse(dto.getNum()); // entity.setTrueFalseScore(dto.getScore()); // break; // //填空 // case GapFilling: // entity.setGapFilling(dto.getNum()); // entity.setGapScore(dto.getScore()); // break; // //简答 // case ShortAnswer: // entity.setShortAnswer(dto.getNum()); // entity.setShortAnswerScore(dto.getScore()); // break; // //计算 // case Calculation: // entity.setCalculation(dto.getNum()); // entity.setCalculationScore(dto.getScore()); // break; // } // } // entity.setScore(score); // examTemplateMapper.removeById(entity.getId()); // baseMapper.insert(entity); return Result.ok("修改成功"); } @@ -198,20 +198,20 @@ List<ExamTemplate> records = page.getRecords(); List<ExamTemplateVO> vos = new ArrayList<>(); for (ExamTemplate examTemplate : records) { ExamTemplateVO vo = new ExamTemplateVO(); BeanUtils.copyProperties(examTemplate,vo); String visibility = vo.getVisibility(); vo.setVisibility(VisibilityEnum.valueOf(visibility).getCode()+""); //整理题目信息为集合 List<TemplateQuestionDTO> questionList = new ArrayList<>(); addQuestionList(questionList,QuestionTypeEnum.SingleChoice.getCode(),examTemplate.getSingleScore(),examTemplate.getSingleChoice()); addQuestionList(questionList,QuestionTypeEnum.MultipleChoice.getCode(),examTemplate.getMultipleScore(),examTemplate.getMultipleChoice()); addQuestionList(questionList,QuestionTypeEnum.TrueFalse.getCode(),examTemplate.getTrueFalseScore(),examTemplate.getTrueFalse()); addQuestionList(questionList,QuestionTypeEnum.GapFilling.getCode(),examTemplate.getGapScore(),examTemplate.getGapFilling()); addQuestionList(questionList,QuestionTypeEnum.ShortAnswer.getCode(),examTemplate.getShortAnswerScore(),examTemplate.getShortAnswer()); addQuestionList(questionList,QuestionTypeEnum.Calculation.getCode(),examTemplate.getCalculationScore(),examTemplate.getCalculation()); vo.setQuestionList(questionList); vos.add(vo); // ExamTemplateVO vo = new ExamTemplateVO(); // BeanUtils.copyProperties(examTemplate,vo); // String visibility = vo.getVisibility(); // vo.setVisibility(VisibilityEnum.valueOf(visibility).getCode()+""); // //整理题目信息为集合 // List<TemplateQuestionDTO> questionList = new ArrayList<>(); // addQuestionList(questionList,QuestionTypeEnum.SingleChoice.getCode(),examTemplate.getSingleScore(),examTemplate.getSingleChoice()); // addQuestionList(questionList,QuestionTypeEnum.MultipleChoice.getCode(),examTemplate.getMultipleScore(),examTemplate.getMultipleChoice()); // addQuestionList(questionList,QuestionTypeEnum.TrueFalse.getCode(),examTemplate.getTrueFalseScore(),examTemplate.getTrueFalse()); // addQuestionList(questionList,QuestionTypeEnum.GapFilling.getCode(),examTemplate.getGapScore(),examTemplate.getGapFilling()); // addQuestionList(questionList,QuestionTypeEnum.ShortAnswer.getCode(),examTemplate.getShortAnswerScore(),examTemplate.getShortAnswer()); // addQuestionList(questionList,QuestionTypeEnum.Calculation.getCode(),examTemplate.getCalculationScore(),examTemplate.getCalculation()); // vo.setQuestionList(questionList); // vos.add(vo); } return Result.ok().data(vos).total(page.getTotal()); } src/main/resources/mapper/ExamPaperMapper.xml
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ycl.jxkg.mapper.ExamPaperMapper"> <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.entity.ExamPaper"> <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.exam.ExamPaperTempDTO"> <id column="id" property="id"/> <result column="name" property="name"/> <result column="subject_id" property="subjectId"/> @@ -15,6 +15,20 @@ <result column="create_user" property="createUser"/> <result column="create_time" property="createTime"/> <result column="deleted" property="deleted"/> <association property="examTemplate" javaType="com.ycl.jxkg.domain.entity.ExamTemplate"> <result column="single_choice" property="singleChoice" /> <result column="single_score" property="singleScore" /> <result column="multiple_choice" property="multipleChoice" /> <result column="multiple_score" property="multipleScore" /> <result column="gap_filling" property="gapFilling" /> <result column="gap_score" property="gapScore" /> <result column="true_false" property="trueFalse" /> <result column="true_false_score" property="trueFalseScore" /> <result column="short_answer" property="shortAnswer" /> <result column="short_answer_score" property="shortAnswerScore" /> <result column="calculation" property="calculation" /> <result column="calculation_score" property="calculationScore" /> </association> </resultMap> <sql id="Base_Column_List"> @@ -31,21 +45,33 @@ <select id="page" resultMap="BaseResultMap" parameterType="com.ycl.jxkg.domain.vo.admin.exam.ExamPaperPageRequestVO"> SELECT <include refid="Base_Column_List"/> FROM t_exam_paper tep.*, tet.single_choice, tet.multiple_choice, tet.gap_filling, tet.true_false, tet.short_answer, tet.calculation, tet.single_score, tet.multiple_score, tet.gap_score, tet.true_false_score, tet.short_answer_score, tet.calculation_score FROM t_exam_paper tep left join t_exam_template tet on tep.id =tet.exam_paper_id <where> and deleted=0 and tep.deleted=0 <if test="id != null "> and id= #{id} and tep.id= #{id} </if> <if test="name != null and name != ''"> and name like concat('%',#{name},'%') and tep.name like concat('%',#{name},'%') </if> <if test="subjectId != null "> and subject_id= #{subjectId} and tep.subject_id= #{subjectId} </if> <if test="paperType != null "> and paper_type= #{paperType} and tep.paper_type= #{paperType} </if> </where> </select> src/main/resources/mapper/ExamTemplateMapper.xml
@@ -22,7 +22,7 @@ <result column="gap_score" property="gapScore" /> <result column="true_false_score" property="trueFalseScore" /> <result column="short_answer_score" property="shortAnswerScore" /> <result column="calculation__score" property="calculationScore" /> <result column="calculation_score" property="calculationScore" /> <result column="create_user" property="createUser" /> <result column="create_time" property="createTime" /> </resultMap> @@ -49,7 +49,7 @@ TET.gap_score, TET.true_false_score, TET.short_answer_score, TET.calculation__score, TET.calculation_score, TET.create_user, TET.create_time, TET.id @@ -80,7 +80,7 @@ TET.gap_score, TET.true_false_score, TET.short_answer_score, TET.calculation__score, TET.calculation_score, TET.create_user, TET.create_time, TET.id @@ -98,6 +98,6 @@ </select> <delete id="removeById"> delete from t_exam_template where id = #{id} delete from t_exam_template where exam_paper_id = #{id} </delete> </mapper>