|
@@ -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>
|