From 9b8264bd45b103476e2f9d662aa8c324a41f3357 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 12 六月 2024 09:10:46 +0800
Subject: [PATCH] 试卷逻辑更改
---
src/main/java/com/ycl/jxkg/controller/admin/ExamPaperController.java | 20 -
src/main/java/com/ycl/jxkg/domain/form/ExamPaperForm.java | 8
src/main/resources/mapper/ExamPaperMapper.xml | 42 +++
src/main/resources/mapper/ExamTemplateMapper.xml | 8
src/main/java/com/ycl/jxkg/mapper/ExamPaperMapper.java | 3
src/main/java/com/ycl/jxkg/service/impl/ExamTemplateServiceImpl.java | 218 ++++++++++----------
src/main/java/com/ycl/jxkg/domain/entity/ExamTemplate.java | 38 ---
src/main/java/com/ycl/jxkg/service/ExamPaperService.java | 8
src/main/java/com/ycl/jxkg/domain/vo/admin/exam/ExamResponseVO.java | 6
src/main/java/com/ycl/jxkg/domain/exam/ExamPaperTempDTO.java | 64 ++++++
src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java | 133 ++++++++++++
11 files changed, 370 insertions(+), 178 deletions(-)
diff --git a/src/main/java/com/ycl/jxkg/controller/admin/ExamPaperController.java b/src/main/java/com/ycl/jxkg/controller/admin/ExamPaperController.java
index 046cc96..2dffa72 100644
--- a/src/main/java/com/ycl/jxkg/controller/admin/ExamPaperController.java
+++ b/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();
}
diff --git a/src/main/java/com/ycl/jxkg/domain/entity/ExamTemplate.java b/src/main/java/com/ycl/jxkg/domain/entity/ExamTemplate.java
index 1e31949..a5436cb 100644
--- a/src/main/java/com/ycl/jxkg/domain/entity/ExamTemplate.java
+++ b/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;
}
diff --git a/src/main/java/com/ycl/jxkg/domain/exam/ExamPaperTempDTO.java b/src/main/java/com/ycl/jxkg/domain/exam/ExamPaperTempDTO.java
new file mode 100644
index 0000000..4bb54e3
--- /dev/null
+++ b/src/main/java/com/ycl/jxkg/domain/exam/ExamPaperTempDTO.java
@@ -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;
+}
diff --git a/src/main/java/com/ycl/jxkg/domain/form/ExamPaperForm.java b/src/main/java/com/ycl/jxkg/domain/form/ExamPaperForm.java
index a80afc7..1055071 100644
--- a/src/main/java/com/ycl/jxkg/domain/form/ExamPaperForm.java
+++ b/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();
diff --git a/src/main/java/com/ycl/jxkg/domain/vo/admin/exam/ExamResponseVO.java b/src/main/java/com/ycl/jxkg/domain/vo/admin/exam/ExamResponseVO.java
index 811b795..3fcc2b5 100644
--- a/src/main/java/com/ycl/jxkg/domain/vo/admin/exam/ExamResponseVO.java
+++ b/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;
}
diff --git a/src/main/java/com/ycl/jxkg/mapper/ExamPaperMapper.java b/src/main/java/com/ycl/jxkg/mapper/ExamPaperMapper.java
index e804abf..7e1b995 100644
--- a/src/main/java/com/ycl/jxkg/mapper/ExamPaperMapper.java
+++ b/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);
diff --git a/src/main/java/com/ycl/jxkg/service/ExamPaperService.java b/src/main/java/com/ycl/jxkg/service/ExamPaperService.java
index d8ee7dd..caa6368 100644
--- a/src/main/java/com/ycl/jxkg/service/ExamPaperService.java
+++ b/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);
}
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 f661b55..0d99bb1 100644
--- a/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
+++ b/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);
+ //濡傛灉鏄殢鏈鸿瘯鍗蜂慨鏀箃emplate琛�
+ 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();
diff --git a/src/main/java/com/ycl/jxkg/service/impl/ExamTemplateServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/ExamTemplateServiceImpl.java
index 81e94fb..695db7e 100644
--- a/src/main/java/com/ycl/jxkg/service/impl/ExamTemplateServiceImpl.java
+++ b/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,53 +115,53 @@
@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);
- return Result.ok("淇敼鎴愬姛");
+// 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());
}
diff --git a/src/main/resources/mapper/ExamPaperMapper.xml b/src/main/resources/mapper/ExamPaperMapper.xml
index 52d8067..2e279f0 100644
--- a/src/main/resources/mapper/ExamPaperMapper.xml
+++ b/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>
diff --git a/src/main/resources/mapper/ExamTemplateMapper.xml b/src/main/resources/mapper/ExamTemplateMapper.xml
index 2175930..d39d1ea 100644
--- a/src/main/resources/mapper/ExamTemplateMapper.xml
+++ b/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>
--
Gitblit v1.8.0