he2802 2 жил өмнө
parent
commit
1b6e608f24

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamTempAddBo.java

@@ -41,4 +41,7 @@ public class ExamTempAddBo {
     private Long orderGoodsId;
     @ApiModelProperty("生成题目数量")
     private Integer number;
+    /** 试卷类型id */
+    @ApiModelProperty("试卷类型id")
+    private Long examPaperId;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamTempEditBo.java

@@ -49,4 +49,8 @@ public class ExamTempEditBo {
     @ApiModelProperty("题目数")
     private Integer number;
 
+    /** 试卷类型id */
+    @ApiModelProperty("试卷类型id")
+    private Long examPaperId;
+
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/bo/ExamTempQueryBo.java

@@ -53,4 +53,7 @@ public class ExamTempQueryBo extends BaseEntity {
 	private Long orderGoodsId;
 	@ApiModelProperty("生成题目数量")
 	private Integer number;
+	/** 试卷类型id */
+	@ApiModelProperty("试卷类型id")
+	private Long examPaperId;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/domain/ExamTemp.java

@@ -44,4 +44,6 @@ private static final long serialVersionUID=1L;
     private Long orderGoodsId;
     /** 题目数 */
     private Integer number;
+    /** 试卷类型id */
+    private Long examPaperId;
 }

+ 11 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamTempServiceImpl.java

@@ -15,6 +15,9 @@ import com.zhongzheng.modules.bank.service.IExamTempQuestionService;
 import com.zhongzheng.modules.bank.service.IExamTempService;
 import com.zhongzheng.modules.bank.vo.ExamTempVo;
 import com.zhongzheng.modules.bank.vo.QuestionVo;
+import com.zhongzheng.modules.course.domain.CourseBusiness;
+import com.zhongzheng.modules.exam.domain.ExamPaper;
+import com.zhongzheng.modules.exam.service.IExamPaperService;
 import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -46,6 +49,9 @@ public class ExamTempServiceImpl extends ServiceImpl<ExamTempMapper, ExamTemp> i
     @Autowired
     private IExamTempQuestionService iExamTempQuestionService;
 
+    @Autowired
+    private IExamPaperService iExamPaperService;
+
     @Override
     public ExamTempVo queryById(Long examId){
         ExamTemp db = this.baseMapper.selectById(examId);
@@ -100,6 +106,10 @@ public class ExamTempServiceImpl extends ServiceImpl<ExamTempMapper, ExamTemp> i
         if(Validator.isEmpty(bo.getNumber())){
             throw new CustomException("题目数量错误");
         }
+        ExamPaper examPaper = iExamPaperService.getOne(new LambdaQueryWrapper<ExamPaper>().eq(ExamPaper::getStatus, 1).eq(ExamPaper::getPaperName,"随机练习").last("limit 1"));
+        if(Validator.isEmpty(examPaper)){
+            throw new CustomException("系统不存在随机练习试卷类型");
+        }
         ExamTempQueryBo queryBo = new ExamTempQueryBo();
         queryBo.setGoodsId(bo.getGoodsId());
         queryBo.setOrderGoodsId(bo.getOrderGoodsId());
@@ -107,7 +117,7 @@ public class ExamTempServiceImpl extends ServiceImpl<ExamTempMapper, ExamTemp> i
         List<QuestionVo> questionlist = getQuestionList(queryBo);
 
         add.setExamName(ServletUtils.getEncoded("随机练习试卷-")+bo.getOrderGoodsId());
-
+        add.setExamPaperId(examPaper.getPaperId());
         add.setCreateTime(DateUtils.getNowTime());
         add.setUpdateTime(DateUtils.getNowTime());
         boolean result = this.save(add);

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/vo/ExamTempVo.java

@@ -56,4 +56,9 @@ public class ExamTempVo {
 	private Integer number;
 	@ApiModelProperty("题目列表")
 	private List<QuestionVo> questionList;
+
+	/** 试卷类型id */
+	@Excel(name = "试卷类型id")
+	@ApiModelProperty("试卷类型id")
+	private Long examPaperId;
 }

+ 1 - 0
zhongzheng-system/src/main/resources/mapper/modules/bank/ExamTempMapper.xml

@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="userId" column="user_id"/>
         <result property="orderGoodsId" column="order_goods_id"/>
         <result property="number" column="number"/>
+        <result property="examPaperId" column="exam_paper_id"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.bank.vo.QuestionVo" id="QuestionResultVo">

+ 76 - 4
zhongzheng-system/src/main/resources/mapper/modules/collect/CollectQuestionMapper.xml

@@ -72,8 +72,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectExamList" parameterType="com.zhongzheng.modules.collect.bo.CollectQuestionQueryBo"  resultMap="CollectQuestionVoResult">
         SELECT
-        e.*,
-        COUNT( cq.question_id ) question_num
+        e.exam_id,
+        e.exam_name,
+        e.create_time,
+        COUNT( cq.question_id ) question_num,
+        1 AS do_mode
         FROM
         collect_question cq
         LEFT JOIN exam e ON cq.exam_id = e.exam_id
@@ -81,6 +84,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN goods g ON g.goods_id = cq.goods_id
         WHERE
         1 = 1
+        AND cq.do_mode = 1
+        AND cq.user_id = #{userId}
+        <if test="paperId != null and paperId != ''">
+            AND e.exam_paper_id = #{paperId}
+        </if>
+        <if test="goodsId != null and goodsId != ''">
+            AND cq.goods_id = #{goodsId}
+        </if>
+        <if test="orderGoodsId != null and orderGoodsId != ''">
+            AND cq.order_goods_id = #{orderGoodsId}
+        </if>
+        <if test="businessId != null and businessId != ''">
+            AND g.business_id = #{businessId}
+        </if>
+        <if test="educationTypeId != null and educationTypeId != ''">
+            AND g.education_type_id = #{educationTypeId}
+        </if>
+        GROUP BY
+        e.exam_id
+        UNION ALL
+        SELECT
+        e.exam_id,
+        e.exam_name,
+        e.create_time,
+        COUNT( cq.question_id ) question_num,
+        2 AS do_mode
+        FROM
+        collect_question cq
+        LEFT JOIN exam_temp e ON cq.exam_id = e.exam_id
+        LEFT JOIN exam_paper ep ON ep.paper_id = e.exam_paper_id
+        LEFT JOIN goods g ON g.goods_id = cq.goods_id
+        WHERE
+        1 = 1
+        AND cq.do_mode = 2
         AND cq.user_id = #{userId}
         <if test="paperId != null and paperId != ''">
             AND e.exam_paper_id = #{paperId}
@@ -100,7 +137,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         GROUP BY
         e.exam_id
         ORDER BY
-        e.create_time desc
+        create_time desc
     </select>
 
     <select id="selectExamQuestionList" parameterType="com.zhongzheng.modules.collect.bo.CollectQuestionQueryBo"  resultMap="QuestionResultVo">
@@ -128,12 +165,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectTypeNum" parameterType="com.zhongzheng.modules.collect.bo.CollectQuestionQueryBo"  resultMap="CollectQuestionVoResult">
         SELECT
             q.type,
-            count( q.question_id ) AS num
+            count( q.question_id ) AS num,
+        1 AS do_mode
         FROM
                 ( SELECT c.* FROM collect_question c
         LEFT JOIN exam e ON c.exam_id = e.exam_id
         LEFT JOIN exam_paper ep ON ep.paper_id = e.exam_paper_id
                 WHERE user_id = #{userId}
+        AND c.do_mode = 1
         <if test="paperId != null and paperId != ''">
             AND e.exam_paper_id = #{paperId}
         </if>
@@ -156,6 +195,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
         GROUP BY
             q.type
+        UNION ALL
+        SELECT
+        q.type,
+        count( q.question_id ) AS num,
+        2 AS do_mode
+        FROM
+        ( SELECT c.* FROM collect_question c
+        LEFT JOIN exam_temp e ON c.exam_id = e.exam_id
+        LEFT JOIN exam_paper ep ON ep.paper_id = e.exam_paper_id
+        WHERE user_id = #{userId}
+        AND c.do_mode = 2
+        <if test="paperId != null and paperId != ''">
+            AND e.exam_paper_id = #{paperId}
+        </if>
+        ) cq
+        LEFT JOIN question q ON cq.question_id = q.question_id
+        LEFT JOIN goods g ON g.goods_id = cq.goods_id
+        WHERE
+        1 = 1
+        <if test="goodsId != null and goodsId != ''">
+            AND cq.goods_id = #{goodsId}
+        </if>
+        <if test="orderGoodsId != null and orderGoodsId != ''">
+            AND cq.order_goods_id = #{orderGoodsId}
+        </if>
+        <if test="businessId != null and businessId != ''">
+            AND g.business_id = #{businessId}
+        </if>
+        <if test="educationTypeId != null and educationTypeId != ''">
+            AND g.education_type_id = #{educationTypeId}
+        </if>
+        GROUP BY
+        q.type
     </select>
 
 </mapper>