<?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.sooka.system.mapper.TUSfzMapper">
    
    <resultMap type="TUSfz" id="TUSfzResult">
        <result property="id"    column="id"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="licenceIssue"    column="licence_issue"    />
        <result property="name"    column="name"    />
        <result property="gender"    column="gender"    />
        <result property="nationality"    column="nationality"    />
        <result property="birthDate"    column="birth_date"    />
        <result property="idcardNo"    column="idcard_no"    />
        <result property="addressPermanent"    column="address_permanent"    />
        <result property="photos"    column="photos"    />
        <result property="photograph"    column="photograph"    />
    </resultMap>

    <sql id="selectTUSfzVo">
        select id, status, remark, del_flag, create_by, create_time, update_by, update_time, licence_issue, name, gender, nationality, birth_date, idcard_no, address_permanent, photos, photograph from t_u_sfz
    </sql>

    <select id="selectTUSfzList" parameterType="TUSfz" resultMap="TUSfzResult">
        <include refid="selectTUSfzVo"/>
        <where>  
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="licenceIssue != null  and licenceIssue != ''"> and licence_issue = #{licenceIssue}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="gender != null  and gender != ''"> and gender = #{gender}</if>
            <if test="nationality != null  and nationality != ''"> and nationality = #{nationality}</if>
            <if test="birthDate != null  and birthDate != ''"> and birth_date = #{birthDate}</if>
            <if test="idcardNo != null  and idcardNo != ''"> and idcard_no = #{idcardNo}</if>
            <if test="addressPermanent != null  and addressPermanent != ''"> and address_permanent = #{addressPermanent}</if>
            <if test="photos != null  and photos != ''"> and photos = #{photos}</if>
            <if test="photograph != null  and photograph != ''"> and photograph = #{photograph}</if>
        </where>
    </select>
    
    <select id="selectTUSfzById" parameterType="String" resultMap="TUSfzResult">
        <include refid="selectTUSfzVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTUSfz" parameterType="TUSfz">
        insert into t_u_sfz
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="status != null">status,</if>
            <if test="remark != null">remark,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="licenceIssue != null">licence_issue,</if>
            <if test="name != null">name,</if>
            <if test="gender != null">gender,</if>
            <if test="nationality != null">nationality,</if>
            <if test="birthDate != null">birth_date,</if>
            <if test="idcardNo != null">idcard_no,</if>
            <if test="addressPermanent != null">address_permanent,</if>
            <if test="photos != null">photos,</if>
            <if test="photograph != null">photograph,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="status != null">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="licenceIssue != null">#{licenceIssue},</if>
            <if test="name != null">#{name},</if>
            <if test="gender != null">#{gender},</if>
            <if test="nationality != null">#{nationality},</if>
            <if test="birthDate != null">#{birthDate},</if>
            <if test="idcardNo != null">#{idcardNo},</if>
            <if test="addressPermanent != null">#{addressPermanent},</if>
            <if test="photos != null">#{photos},</if>
            <if test="photograph != null">#{photograph},</if>
         </trim>
    </insert>

    <update id="updateTUSfz" parameterType="TUSfz">
        update t_u_sfz
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null">status = #{status},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="licenceIssue != null">licence_issue = #{licenceIssue},</if>
            <if test="name != null">name = #{name},</if>
            <if test="gender != null">gender = #{gender},</if>
            <if test="nationality != null">nationality = #{nationality},</if>
            <if test="birthDate != null">birth_date = #{birthDate},</if>
            <if test="idcardNo != null">idcard_no = #{idcardNo},</if>
            <if test="addressPermanent != null">address_permanent = #{addressPermanent},</if>
            <if test="photos != null">photos = #{photos},</if>
            <if test="photograph != null">photograph = #{photograph},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTUSfzById" parameterType="String">
        delete from t_u_sfz where id = #{id}
    </delete>

    <delete id="deleteTUSfzByIds" parameterType="String">
        delete from t_u_sfz where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>