<?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="jnpf.cultivate.mapper.FtbCultivateExamFrequncyLogMapper">

    <resultMap id="BaseResultMap" type="jnpf.model.cultivate.po.exam.FtbCultivateExamFrequencyLog">
        <id property="id" column="F_Id" jdbcType="VARCHAR"/>
        <result property="examId" column="F_ExamId" jdbcType="VARCHAR"/>
        <result property="userId" column="F_UserId" jdbcType="VARCHAR"/>
        <result property="creatorUserId" column="F_CreatorUserId" jdbcType="VARCHAR"/>
        <result property="creatorTime" column="F_CreatorTime" jdbcType="TIMESTAMP"/>
        <result property="tenantId" column="F_TenantId" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        F_Id,F_ExamId,F_UserId,F_CreatorUserId,F_CreatorTime,F_TenantId
    </sql>

    <!--查询用户在一定时间范围内的考试次数-->
    <select id="queryExamNum" resultType="java.lang.Integer">
        select count(1)
        from ftb_cultivate_exam_frequency_log
        where F_ExamId = #{examId}
          and F_UserId = #{userId}
          and F_CreatorTime between #{startTime} AND #{endTime}
    </select>
    <select id="queryExamNumByDateStr" resultType="java.lang.Integer">
        select count(1)
        from ftb_cultivate_exam_frequency_log
        where F_ExamId = #{examId}
        and F_UserId = #{userId}
        <if test="null != startDateStr and null != endDateStr">
            and DATE_FORMAT(F_CreatorTime, '%Y-%m-%d') between #{startDateStr} AND #{endDateStr}
        </if>
    </select>
</mapper>
