<?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.yifu.cloud.plus.v1.business.mapper.cert.TCertInfoMapper">
    <resultMap id="tCertInfoMap" type="com.yifu.cloud.plus.v1.business.entity.cert.TCertInfo">
        <id property="id" column="id"/>
        <result property="certType" column="cert_type"/>
        <result property="status" column="status"/>
        <result property="empName" column="emp_name"/>
        <result property="certNum" column="cert_num"/>
        <result property="jobClass" column="job_class"/>
        <result property="operationItem" column="operation_item"/>
        <result property="receiveTime" column="receive_time"/>
        <result property="termValidityStart" column="term_validity_start"/>
        <result property="termValidityEnd" column="term_validity_end"/>
        <result property="reviewDate" column="review_date"/>
        <result property="ossUrlFront" column="oss_url_front"/>
        <result property="ossUrlBack" column="oss_url_back"/>
        <result property="createUser" column="create_user"/>
        <result property="createTime" column="create_time"/>
        <result property="empIdcard" column="emp_idcard"/>
        <result property="organId" column="organ_id"/>
        <result property="post" column="post"/>
        <result property="label" column="label"/>
        <result property="businessTelecomNumber" column="business_telecom_number"/>
        <result property="deleteFlag" column="delete_flag"/>
    </resultMap>
    <sql id="Base_Column_List">
        a.id,
        a.cert_type,
        a.status,
        a.emp_name,
        a.cert_num,
        a.job_class,
        a.operation_item,
        a.receive_time,
        a.term_validity_start,
        a.term_validity_end,
        a.review_date,
        a.oss_url_front,
        a.oss_url_back,
        a.create_user,
        a.create_time,
        a.emp_idcard,
        a.organ_id,
        a.post,
        a.label,
        a.delete_flag,
        a.business_telecom_number
    </sql>
    <sql id="tCertInfo_where">
        <if test="tCertInfo != null">
            <if test="tCertInfo.deleteFlag != null and tCertInfo.deleteFlag.trim() != ''">
                AND a.delete_flag = #{tCertInfo.deleteFlag}
            </if>
            <if test="tCertInfo.organId != null and tCertInfo.organId != 1">
                AND (b.id = #{tCertInfo.organId} or b.tree_logo like concat('%-', #{tCertInfo.organId},'-%'))
            </if>
            <if test="tCertInfo.post != null and tCertInfo.post.trim() != ''">
                AND a.post like concat('%',#{tCertInfo.post},'%')
            </if>
            <if test="tCertInfo.label != null and tCertInfo.label.trim() != ''">
                AND a.label  like concat('%',#{tCertInfo.label},'%')
            </if>
            <if test="tCertInfo.businessTelecomNumber != null and tCertInfo.businessTelecomNumber.trim() != ''">
                AND a.business_telecom_number  like concat('%',#{tCertInfo.businessTelecomNumber},'%')
            </if>
            <if test="tCertInfo.id != null and tCertInfo.id.trim() != ''">
                AND a.id = #{tCertInfo.id}
            </if>
            <if test="tCertInfo.certType != null and tCertInfo.certType.trim() != ''">
                AND a.cert_type = #{tCertInfo.certType}
            </if>
            <if test="tCertInfo.status != null and tCertInfo.status.trim() != ''">
                AND a.status = #{tCertInfo.status}
            </if>
            <if test="tCertInfo.empName != null and tCertInfo.empName.trim() != ''">
                AND a.emp_name like concat('%',#{tCertInfo.empName},'%')
            </if>
            <if test="tCertInfo.certNum != null and tCertInfo.certNum.trim() != ''">
                AND a.cert_num = #{tCertInfo.certNum}
            </if>
            <if test="tCertInfo.jobClass != null and tCertInfo.jobClass.trim() != ''">
                AND a.job_class = #{tCertInfo.jobClass}
            </if>
            <if test="tCertInfo.operationItem != null and tCertInfo.operationItem.trim() != ''">
                AND a.operation_item like concat('%',#{tCertInfo.operationItem},'%')
            </if>
            <if test="tCertInfo.receiveTime != null and tCertInfo.receiveTime.trim() != ''">
                AND a.receive_time = #{tCertInfo.receiveTime}
            </if>
            <if test="tCertInfo.termValidityStart != null and tCertInfo.termValidityStart.trim() != ''">
                AND a.term_validity_start >= #{tCertInfo.termValidityStart}
            </if>
            <if test="tCertInfo.termValidityEnd != null and tCertInfo.termValidityEnd.trim() != ''">
                AND a.term_validity_end <![CDATA[ <= ]]> #{tCertInfo.termValidityEnd}
            </if>
            <if test="tCertInfo.reviewDate != null">
                AND a.review_date = #{tCertInfo.reviewDate}
            </if>
            <if test="tCertInfo.ossUrlFront != null and tCertInfo.ossUrlFront.trim() != ''">
                AND a.oss_url_front = #{tCertInfo.ossUrlFront}
            </if>
            <if test="tCertInfo.ossUrlBack != null and tCertInfo.ossUrlBack.trim() != ''">
                AND a.oss_url_back = #{tCertInfo.ossUrlBack}
            </if>
            <if test="tCertInfo.createUser != null and tCertInfo.createUser.trim() != ''">
                AND a.create_user = #{tCertInfo.createUser}
            </if>
            <if test="tCertInfo.createTime != null">
                AND a.create_time = #{tCertInfo.createTime}
            </if>
            <if test="tCertInfo.empIdcard != null and tCertInfo.empIdcard.trim() != ''">
                AND a.emp_idcard = #{tCertInfo.empIdcard}
            </if>
        </if>
    </sql>
    <!--tCertInfo简单分页查询-->
    <select id="getTCertInfoPage" resultMap="tCertInfoMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_cert_info a
        left join t_bus_dept b on  a.organ_id=b.id
        <where>
            1=1
            <include refid="tCertInfo_where"/>
        </where>
        order by a.create_time DESC
    </select>

    <!--tCertInfo简单分页查询-->
    <select id="getCertInfoNoPage" resultMap="tCertInfoMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_cert_info a
        left join t_bus_dept b on  a.organ_id=b.id
        <where>
            1=1
            <include refid="tCertInfo_where"/>
        </where>
    </select>
</mapper>
