From 792efe2ed891a345ed48537bd5b5e4d1246d20b3 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期五, 07 六月 2024 17:10:50 +0800
Subject: [PATCH] 试卷查看题目接口

---
 src/main/java/com/ycl/jxkg/controller/admin/ExamPaperController.java      |   25 +++++-
 src/main/java/com/ycl/jxkg/mapper/ExamPaperQuestionMapper.java            |   10 ++
 src/main/java/com/ycl/jxkg/domain/vo/admin/paper/ExamPaperQuestionVO.java |   20 +++++
 src/main/java/com/ycl/jxkg/domain/question/QuestionDTO.java               |   52 +++++++++++++
 src/main/resources/mapper/ExamPaperQuestionMapper.xml                     |   31 +++++++
 src/main/java/com/ycl/jxkg/service/impl/ExamPaperQuestionServiceImpl.java |   20 +++++
 src/main/java/com/ycl/jxkg/service/ExamPaperQuestionService.java          |    9 ++
 src/main/java/com/ycl/jxkg/domain/entity/ExamPaperQuestion.java           |   22 +++++
 8 files changed, 185 insertions(+), 4 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 e51a998..046cc96 100644
--- a/src/main/java/com/ycl/jxkg/controller/admin/ExamPaperController.java
+++ b/src/main/java/com/ycl/jxkg/controller/admin/ExamPaperController.java
@@ -3,11 +3,14 @@
 import com.ycl.jxkg.base.BaseApiController;
 import com.ycl.jxkg.base.Result;
 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.vo.admin.paper.ExamPaperQuestionVO;
 import com.ycl.jxkg.enums.VisibilityEnum;
 import com.ycl.jxkg.group.Add;
 import com.ycl.jxkg.group.Update;
 import com.ycl.jxkg.mapper.ExamPaperMapper;
+import com.ycl.jxkg.service.ExamPaperQuestionService;
 import com.ycl.jxkg.service.ExamPaperService;
 import com.ycl.jxkg.utils.DateTimeUtil;
 import com.ycl.jxkg.utils.PageInfoHelper;
@@ -18,6 +21,7 @@
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -28,10 +32,12 @@
 @RestController("AdminExamPaperController")
 @RequestMapping(value = "/api/admin/exam/paper")
 public class ExamPaperController extends BaseApiController {
-
-    private final ExamPaperService examPaperService;
-
-    private final ExamPaperMapper baseMapper;
+    @Autowired
+    private ExamPaperService examPaperService;
+    @Autowired
+    private ExamPaperQuestionService examPaperQuestionService;
+    @Autowired
+    private ExamPaperMapper baseMapper;
 
     @RequestMapping(value = "/page", method = RequestMethod.POST)
     public Result<PageInfo<ExamResponseVO>> pageList(@RequestBody ExamPaperPageRequestVO model) {
@@ -65,11 +71,22 @@
         if (!StringUtils.isBlank(form.getVisibility())) {
             form.setVisibility(VisibilityEnum.fromCode(form.getVisibility()).getName());
         }
+        //TODO:淇敼鑱旇〃閲岀殑鍒嗘暟
         ExamPaper entity = ExamPaperForm.getEntityByForm(form,null);
         examPaperService.updateById(entity);
         return Result.ok();
     }
 
+    @RequestMapping(value = "/editQuestion", method = RequestMethod.POST)
+    public Result editQuestion(@RequestBody  ExamPaperForm form) {
+
+        return Result.ok();
+    }
+    @RequestMapping(value = "/selectQuestion/{id}", method = RequestMethod.POST)
+    public Result<ExamPaperQuestion> selectQuestion(@PathVariable Integer id) {
+        ExamPaperQuestion vo = examPaperQuestionService.selectById(id);
+        return Result.ok(vo);
+    }
     @RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
     public Result<ExamPaperEditRequestVO> select(@PathVariable Integer id) {
         ExamPaperEditRequestVO vm = examPaperService.examPaperToVM(id);
diff --git a/src/main/java/com/ycl/jxkg/domain/entity/ExamPaperQuestion.java b/src/main/java/com/ycl/jxkg/domain/entity/ExamPaperQuestion.java
new file mode 100644
index 0000000..6f41964
--- /dev/null
+++ b/src/main/java/com/ycl/jxkg/domain/entity/ExamPaperQuestion.java
@@ -0,0 +1,22 @@
+package com.ycl.jxkg.domain.entity;
+
+import com.ycl.jxkg.domain.question.QuestionDTO;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+@Data
+public class ExamPaperQuestion {
+    private Integer id;
+    private String name;
+    private Integer templateId;
+    private Integer paperType;
+    private Integer subjectId;
+    private Integer suggestTime;
+    private Integer deductType;
+    private BigDecimal deductTypeScore;
+    private BigDecimal score;
+
+    private List<QuestionDTO> questions;
+
+}
diff --git a/src/main/java/com/ycl/jxkg/domain/question/QuestionDTO.java b/src/main/java/com/ycl/jxkg/domain/question/QuestionDTO.java
new file mode 100644
index 0000000..6764832
--- /dev/null
+++ b/src/main/java/com/ycl/jxkg/domain/question/QuestionDTO.java
@@ -0,0 +1,52 @@
+package com.ycl.jxkg.domain.question;
+
+import com.ycl.jxkg.domain.base.AbsEntity;
+import com.ycl.jxkg.enums.general.StatusEnum;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+@Data
+public class QuestionDTO extends AbsEntity {
+    /**
+     * 	1.鍗曢�夐 2.澶氶�夐 3.鍒ゆ柇棰� 4.濉┖棰� 5.绠�绛旈
+     */
+    private Integer questionType;
+
+    /**
+     * 瀛︾
+     */
+    private Integer subjectId;
+
+    /**
+     * 棰樼洰闅惧害
+     */
+    private Integer difficult;
+
+    /**
+     * 姝g‘绛旀
+     */
+    private String correct;
+
+    /**
+     * 棰樼洰 濉┖銆� 棰樺共銆佽В鏋愩�佺瓟妗堢瓑淇℃伅
+     */
+    private String content;
+
+    /**
+     * 鍒涘缓浜�
+     */
+    private Integer createUser;
+
+    /**
+     * 1.鍚敤銆�2.绂佺敤
+     */
+    private StatusEnum status;
+
+    /**
+     * 鍒涘缓鏃堕棿
+     */
+    private Date createTime;
+
+    private BigDecimal score;
+}
diff --git a/src/main/java/com/ycl/jxkg/domain/vo/admin/paper/ExamPaperQuestionVO.java b/src/main/java/com/ycl/jxkg/domain/vo/admin/paper/ExamPaperQuestionVO.java
new file mode 100644
index 0000000..466c490
--- /dev/null
+++ b/src/main/java/com/ycl/jxkg/domain/vo/admin/paper/ExamPaperQuestionVO.java
@@ -0,0 +1,20 @@
+package com.ycl.jxkg.domain.vo.admin.paper;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+@Data
+public class ExamPaperQuestionVO {
+    private Integer id;
+    private String name;
+    private Integer templateId;
+    private Integer paperType;
+    private Integer subjectId;
+    private Integer suggestTime;
+    private Integer deductType;
+    private BigDecimal deductTypeScore;
+    private BigDecimal score;
+    private Map<Integer,Object> questionMap;
+}
diff --git a/src/main/java/com/ycl/jxkg/mapper/ExamPaperQuestionMapper.java b/src/main/java/com/ycl/jxkg/mapper/ExamPaperQuestionMapper.java
new file mode 100644
index 0000000..6991181
--- /dev/null
+++ b/src/main/java/com/ycl/jxkg/mapper/ExamPaperQuestionMapper.java
@@ -0,0 +1,10 @@
+package com.ycl.jxkg.mapper;
+
+import com.ycl.jxkg.domain.entity.ExamPaperQuestion;
+import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperQuestionVO;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface ExamPaperQuestionMapper {
+    ExamPaperQuestion selectById(Integer id);
+}
diff --git a/src/main/java/com/ycl/jxkg/service/ExamPaperQuestionService.java b/src/main/java/com/ycl/jxkg/service/ExamPaperQuestionService.java
new file mode 100644
index 0000000..883c0ca
--- /dev/null
+++ b/src/main/java/com/ycl/jxkg/service/ExamPaperQuestionService.java
@@ -0,0 +1,9 @@
+package com.ycl.jxkg.service;
+
+import com.ycl.jxkg.domain.entity.ExamPaperQuestion;
+import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperQuestionVO;
+
+public interface ExamPaperQuestionService {
+
+    ExamPaperQuestion selectById(Integer id);
+}
diff --git a/src/main/java/com/ycl/jxkg/service/impl/ExamPaperQuestionServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/ExamPaperQuestionServiceImpl.java
new file mode 100644
index 0000000..c30fce4
--- /dev/null
+++ b/src/main/java/com/ycl/jxkg/service/impl/ExamPaperQuestionServiceImpl.java
@@ -0,0 +1,20 @@
+package com.ycl.jxkg.service.impl;
+
+import com.ycl.jxkg.domain.entity.ExamPaperQuestion;
+import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperQuestionVO;
+import com.ycl.jxkg.mapper.ExamPaperQuestionMapper;
+import com.ycl.jxkg.service.ExamPaperQuestionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ExamPaperQuestionServiceImpl implements ExamPaperQuestionService {
+    @Autowired
+    private ExamPaperQuestionMapper examPaperQuestionMapper;
+
+    @Override
+    public ExamPaperQuestion selectById(Integer id) {
+
+        return  examPaperQuestionMapper.selectById(id);
+    }
+}
diff --git a/src/main/resources/mapper/ExamPaperQuestionMapper.xml b/src/main/resources/mapper/ExamPaperQuestionMapper.xml
new file mode 100644
index 0000000..43dc358
--- /dev/null
+++ b/src/main/resources/mapper/ExamPaperQuestionMapper.xml
@@ -0,0 +1,31 @@
+<?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.ExamPaperQuestionMapper">
+
+    <resultMap id="ExamPaperQuestionMap" type="com.ycl.jxkg.domain.entity.ExamPaperQuestion">
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="subject_id" property="subjectId"/>
+        <result column="paper_type" property="paperType"/>
+        <result column="score" property="score"/>
+        <result column="suggest_time" property="suggestTime"/>
+        <collection property="questions" ofType="com.ycl.jxkg.domain.question.QuestionDTO">
+            <id column="questionId" property="id"/>
+            <result column="questionScore" property="score"/>
+            <result column="question_type" property="questionType"/>
+            <result column="difficult" property="difficult"/>
+            <result column="correct" property="correct"/>
+            <result column="content" property="content"/>
+        </collection>
+    </resultMap>
+
+    <select id="selectById" resultMap="ExamPaperQuestionMap">
+        select tep.id,tep.name,tep.subject_id,tep.paper_type,tep.score,tep.suggest_time,
+               tepq.score as questionScore,tq.id as questionId,tq.question_type,tq.difficult,tq.correct,tq.content
+        from t_exam_paper tep
+        left join t_exam_paper_question tepq on tep.id =tepq.exam_paper_id
+        left join t_question tq on tepq.question_id = tq.id
+        where tep.id = #{id} and tq.status = 1 and tq.deleted = 0
+    </select>
+
+</mapper>

--
Gitblit v1.8.0