<?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.check.mapper.TCheckIdCardMapper">
    <resultMap id="tCheckIdCardMap" type="com.yifu.cloud.plus.v1.check.entity.TCheckIdCard">
        <id property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="idCard" column="id_card"/>
        <result property="isTrue" column="is_true"/>
        <result property="reason" column="reason"/>
        <result property="type" column="type"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createTime" column="CREATE_TIME"/>
    </resultMap>
    <sql id="Base_Column_List">
             a.id,
                  a.name,
                  a.id_card,
                  a.is_true,
                  a.reason,
                  a.type,
                  a.CREATE_USER,
                  a.CREATE_TIME
         </sql>
    <sql id="tCheckIdCard_where">
        <if test="tCheckIdCard != null">
            <if test="tCheckIdCard.id != null and tCheckIdCard.id.trim() != ''">
                AND a.id = #{tCheckIdCard.id}
            </if>
            <if test="tCheckIdCard.name != null and tCheckIdCard.name.trim() != ''">
                AND a.name = #{tCheckIdCard.name}
            </if>
            <if test="tCheckIdCard.idCard != null and tCheckIdCard.idCard.trim() != ''">
                AND a.id_card = #{tCheckIdCard.idCard}
            </if>
            <if test="tCheckIdCard.isTrue != null">
                AND a.is_true = #{tCheckIdCard.isTrue}
            </if>
        </if>
    </sql>
    <!--tCheckIdCard简单分页查询-->
    <select id="getTCheckIdCardPage" resultMap="tCheckIdCardMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_check_id_card a
        <where>
            1=1
            <include refid="tCheckIdCard_where"/>
        </where>
    </select>

    <!--获取所有数据-->
    <select id="getAllList" resultMap="tCheckIdCardMap">
        SELECT
            <include refid="Base_Column_List"/>
        FROM t_check_id_card a
        <where>
            1=1
            <include refid="tCheckIdCard_where"/>
        </where>
        order by a.CREATE_TIME desc
    </select>

	<select id="getAllListByList" resultMap="tCheckIdCardMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_check_id_card a
		where a.id_card in
		<foreach item="item" index="index" collection="idCardList" open="(" separator="," close=")">
			#{item}
		</foreach>
		order by a.CREATE_TIME desc
	</select>

	<select id="getTrueListByList" resultMap="tCheckIdCardMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_check_id_card a
		where a.is_true = 1 and a.id_card in
		<foreach item="item" index="index" collection="idCardList" open="(" separator="," close=")">
			#{item}
		</foreach>
		order by a.CREATE_TIME desc
	</select>

</mapper>
