<?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.FtbCultivateExamMapper">

    <!--查询考试列表-->
    <select id="pagingQuery" resultType="jnpf.model.cultivate.resp.ExamListVo">
        SELECT
        a.F_Id AS id,
        a.F_ExamId AS examId,
        a.F_CreatorTime AS creatorTime,
        a.F_CreatorUserId AS creatorUserId,
        a.F_LastModifyUserId AS lastModifyUserId,
        a.F_LastModifyTime AS lastModifyTime,
        a.F_TenantId AS tenantId,
        a.F_PaperId AS paperId,
        a.F_ExamType AS examType,
        a.F_EnabledMark AS enabledMark,
        a.F_Description AS description,
        a.F_ExamMemberId AS examMemberId,
        a.F_StartTime AS startTime,
        a.F_EndTime AS endTime,
        a.F_ExamName AS examName,
        a.F_ExamTime AS examTime,
        a.F_ExcellentType AS excellentType,
        a.F_ExcellentMark AS excellentMark,
        a.F_PassType AS passType,
        a.F_PassMark AS passMark,
        a.F_PostId AS postId,
        a.F_PostRankId AS postRankId,
        a.F_Status as status,
        a.F_ExamLimitation  AS examlimitation,
        a.F_NeedUpdate   AS NeedUpdate,
        a.F_VersionBatch AS versionBatch,
        a.F_PaperInfo    As paperInfo,
        b.F_Name AS paperName,
        b.F_QuestionNumber AS questionNum,
        b.F_TotalScore AS totleScore
        FROM
        ftb_cultivate_exam a
        LEFT JOIN ftb_cultivate_test_paper b ON a.F_PaperId = b.F_Id
        <where>
            a.F_EnabledMark = 1
            <if test="params.keyword!= null and params.keyword!= ''">
                and (
                a.F_ExamName like CONCAT('%',#{params.keyword},'%')
                or b.F_Name like CONCAT('%',#{params.keyword},'%')
                or a.F_ExamId =#{params.keyword}
                )
            </if>
            <if test="params.postId!= null and params.postId!= ''">
                and a.F_PostId like CONCAT('%',#{params.postId},'%')
            </if>
            <if test="params.postionId!= null and params.postionId!= ''">
                and a.F_PostRankId like CONCAT('%',#{params.postionId},'%')
            </if>
            <if test="params.examType!= null">
                and a.F_ExamType =#{params.examType}
            </if>

            <if test="params.needUpdate!= null and params.needUpdate!= '0'">
                and a.F_NeedUpdate =#{params.needUpdate}
            </if>


        </where>
        order by a.F_CreatorTime desc
    </select>
    <!--岗位考试合格后才能进行鉴定,0否1是-->
    <select id="queryExamAndIdentifyConfig" resultType="java.lang.Integer">
        SELECT F_Qualified FROM ftb_cultivate_position WHERE F_EnabledMark = 0 AND F_PostId = #{positionId} limit 1
    </select>
</mapper>