123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <?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.zhongzheng.modules.bank.mapper.ExamMapper">
- <resultMap type="com.zhongzheng.modules.bank.domain.Exam" id="ExamResult">
- <result property="examId" column="exam_id"/>
- <result property="status" column="status"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="prefixName" column="prefix_name"/>
- <result property="code" column="code"/>
- <result property="examName" column="exam_name"/>
- <result property="publishStatus" column="publish_status"/>
- <result property="year" column="year"/>
- <result property="cityId" column="city_id"/>
- <result property="provinceId" column="province_id"/>
- <result property="examPaperId" column="exam_paper_id"/>
- <result property="answerTime" column="answer_time"/>
- <result property="examPaperId" column="exam_paper_id"/>
- <result property="answerNum" column="answer_num"/>
- <result property="sort" column="sort"/>
- <result property="createBy" column="create_by"/>
- <result property="doType" column="do_type"/>
- <result property="simulateConfigJson" column="simulate_config_json"/>
- <result property="simulateStatus" column="simulate_status"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.bank.vo.ExamVo" id="ExamVoResult">
- <result property="examId" column="exam_id"/>
- <result property="status" column="status"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="prefixName" column="prefix_name"/>
- <result property="code" column="code"/>
- <result property="examName" column="exam_name"/>
- <result property="publishStatus" column="publish_status"/>
- <result property="year" column="year"/>
- <result property="cityId" column="city_id"/>
- <result property="provinceId" column="province_id"/>
- <result property="examPaperId" column="exam_paper_id"/>
- <result property="answerTime" column="answer_time"/>
- <result property="examPaperId" column="exam_paper_id"/>
- <result property="answerNum" column="answer_num"/>
- <result property="sort" column="sort"/>
- <result property="educationName" column="education_name"/>
- <result property="projectName" column="project_name"/>
- <result property="businessName" column="business_name"/>
- <result property="educationTypeId" column="education_type_id"/>
- <result property="businessId" column="business_id"/>
- <result property="subjectId" column="subject_id"/>
- <result property="projectId" column="project_id"/>
- <result property="subjectName" column="subject_name"/>
- <result property="doType" column="do_type"/>
- <result property="simulateConfigJson" column="simulate_config_json"/>
- <result property="simulateStatus" column="simulate_status"/>
- <result property="questionNum" column="question_num"/>
- <result property="recordStatus" column="record_status"/>
- <result property="doQuestionNum" column="do_question_num"/>
- <result property="paperName" column="paper_name"/>
- <collection property="goodsList" column="exam_id" select="findGoodsList"/>
- </resultMap>
- <select id="findGoodsList" resultMap="GoodsListResult">
- SELECT
- g.goods_name,
- g.goods_id
- FROM
- goods_attached ga
- LEFT JOIN goods g ON ga.goods_id = g.goods_id
- WHERE
- ga.major_id =#{exam_id} AND ga.type = 3
- </select>
- <resultMap type="com.zhongzheng.modules.bank.vo.ExamGoodsVo" id="GoodsListResult">
- <result property="goodsName" column="goods_name"/>
- <result property="goodsId" column="goods_id"/>
- </resultMap>
- <select id="getList" parameterType="com.zhongzheng.modules.bank.bo.ExamQueryBo" resultMap="ExamVoResult">
- SELECT
- e.*,
- qb.education_type_id,
- qb.business_id,
- qb.project_id,
- qb.subject_id,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- cs.subject_name,
- eq.question_num,
- ep.paper_name
- FROM
- exam e
- LEFT JOIN exam_paper ep ON e.exam_paper_id = ep.paper_id
- LEFT JOIN question_business qb ON e.exam_id = qb.major_id
- AND qb.type = 2
- LEFT JOIN course_education_type cet ON qb.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON qb.project_id = cpt.id
- LEFT JOIN course_business cb ON qb.business_id = cb.id
- LEFT JOIN course_subject cs ON cs.id = qb.subject_id
- LEFT JOIN (SELECT count(*) question_num,exam_id from exam_question GROUP BY exam_id)eq on eq.exam_id = e.exam_id
- where 1=1
- <if test="status != null and status.size()!=0 ">
- AND e.status in
- <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="examIds != null and examIds.size()!=0 ">
- AND e.exam_id in
- <foreach collection="examIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="paperName != null and paperName != ''">
- AND ep.paper_name like concat('%', #{paperName}, '%')
- </if>
- <if test="educationTypeId != null and educationTypeId != ''">
- AND cet.id = #{educationTypeId}
- </if>
- <if test="examId != null and examId != ''">
- AND e.exam_id = #{examId}
- </if>
- <if test="subjectId != null and subjectId != ''">
- AND cs.id = #{subjectId}
- </if>
- <if test="businessId != null and businessId != ''">
- AND cb.id = #{businessId}
- </if>
- <if test="projectId != null and projectId != ''">
- AND cpt.id = #{projectId}
- </if>
- <if test="examPaperId != null and examPaperId != ''">
- AND e.exam_paper_id = #{examPaperId}
- </if>
- <if test="publishStatus != null ">
- AND e.publish_status = #{publishStatus}
- </if>
- <if test="examName != null and examName != ''">
- AND e.exam_name like concat('%', #{examName}, '%')
- </if>
- <if test="prefixName != null and prefixName != ''">
- AND e.prefix_name like concat('%', #{prefixName}, '%')
- </if>
- <if test="key != null and key != ''">
- AND (e.exam_name like concat('%', #{key}, '%') or e.prefix_name like concat('%', #{key}, '%') or e.code = #{key})
- </if>
- <if test="exclude != null and exclude == 1">
- AND ep.paper_name NOT IN('每日一练','随机练习')
- </if>
- ORDER BY e.exam_id DESC
- </select>
- <select id="getPaperExamList" parameterType="com.zhongzheng.modules.exam.bo.ExamPaperQueryBo" resultMap="ExamVoResult">
- SELECT
- e.*,
- count( eq.question_id ) question_num,
- ifnull( (select `status` from user_exam_record uer where uer.exam_id = e.exam_id and uer.user_id = #{userId} and uer.order_goods_id = #{orderGoodsId} ORDER BY uer.record_id desc limit 1),-1) record_status,
- ifnull( (select do_question_num from user_exam_record uer where uer.exam_id = e.exam_id and uer.user_id = #{userId} and uer.order_goods_id = #{orderGoodsId} ORDER BY uer.record_id desc limit 1),0) do_question_num
- FROM
- exam e
- LEFT JOIN exam_question eq ON e.exam_id = eq.exam_id
- WHERE
- e.exam_id IN (
- SELECT
- exam_id
- FROM
- question_chapter_exam
- WHERE
- FIND_IN_SET(
- chapter_exam_id,
- (
- SELECT
- concat(
- IFNULL(( SELECT GROUP_CONCAT( major_id ) eids FROM goods_attached WHERE goods_id = #{goodsId} AND type = 2 ), '' ),
- ',',
- IFNULL(
- (
- SELECT
- GROUP_CONCAT( chapter_exam_id ) eids2
- FROM
- question_module_chapter
- WHERE
- module_exam_id IN ( SELECT major_id FROM goods_attached WHERE goods_id = #{goodsId} AND type = 1 )),
- ''
- )))) UNION
- SELECT
- major_id AS exam_id
- FROM
- goods_attached
- WHERE
- goods_id = #{goodsId}
- AND type = 3
- )
- AND e.`status` = 1 AND e.exam_paper_id = #{paperId} GROUP BY
- e.exam_id
- </select>
- <select id="getExamByTenant" parameterType="map" resultType="com.zhongzheng.modules.bank.domain.Exam">
- select * from exam where `code` = #{code} and tenant_id = #{newTenantId}
- </select>
- </mapper>
|