<?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.user.mapper.UserBankRecordMapper">

    <resultMap type="com.zhongzheng.modules.user.domain.UserBankRecord" id="UserBankRecordResult">
        <result property="recordId" column="record_id"/>
        <result property="type" column="type"/>
        <result property="simulateId" column="simulate_id"/>
        <result property="examId" column="exam_id"/>
        <result property="bankId" column="bank_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="userId" column="user_id"/>
        <result property="status" column="status"/>
        <result property="goodsId" column="goods_id"/>
        <result property="reportStatus" column="report_status"/>
        <result property="courseId" column="course_id"/>
        <result property="sectionId" column="section_id"/>
        <result property="moduleId" column="module_id"/>
        <result property="chapterId" column="chapter_id"/>
        <result property="performance" column="performance"/>
        <result property="gradeId" column="grade_id"/>
        <result property="currentStatus" column="current_status"/>
    </resultMap>

    <select id="getUserExamDoNum" parameterType="com.zhongzheng.modules.user.bo.UserBankRecordQueryBo" resultType="Long">
        SELECT
            IFNULL(count(*),0)
        FROM
        user_bank_record ubr
        WHERE
        1 =1
        <if test="chapterId != null and chapterId != ''">
            AND ubr.chapter_id = #{chapterId}
        </if>
        <if test="moduleId != null and moduleId != ''">
            AND ubr.module_id = #{moduleId}
        </if>
        <if test="courseId != null and courseId != ''">
            AND ubr.course_id = #{courseId}
        </if>
        <if test="gradeId != null and gradeId != ''">
            AND ubr.grade_id = #{gradeId}
        </if>
        <if test="goodsId != null and goodsId != ''">
            AND ubr.goods_id = #{goodsId}
        </if>
        <if test="examId != null and examId != ''">
            AND ubr.exam_id = #{examId}
        </if>
        AND ubr.user_id = #{userId}
    </select>


</mapper>
