<?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.goldenwater.slaj.sins.mapper.SawfCredSaprMapper">
    <resultMap type="com.goldenwater.slaj.sins.domain.SawfCredSapr" id="SawfCredSaprResult">
        <result property="guid" column="guid"/>
        <result property="unitName" column="unit_name"/>
        <result property="unitSocCreCode" column="unit_soc_cre_code"/>
        <result property="blackListStartDate" column="black_list_start_date"/>
        <result property="blackListEndDate" column="black_list_end_date"/>
        <result property="blackListReleWiun" column="black_list_rele_wiun"/>
        <result property="blackListReas" column="black_list_reas"/>
        <result property="note" column="note"/>
        <result property="collTime" column="coll_time"/>
        <result property="updTime" column="upd_time"/>
        <result property="recPers" column="rec_pers"/>
    </resultMap>

    <sql id="selectSawfCredSaprVo">
        select guid, unit_name, unit_soc_cre_code, black_list_start_date, black_list_end_date, black_list_rele_wiun, black_list_reas, note, coll_time, upd_time, rec_pers from sawf_cred_sapr
    </sql>

    <select id="selectSawfCredSaprByGuid" parameterType="String" resultMap="SawfCredSaprResult">
        <include refid="selectSawfCredSaprVo"/> where guid = #{guid}
    </select>

    <select id="selectSawfCredSaprList" parameterType="com.goldenwater.slaj.sins.domain.SawfCredSapr" resultMap="SawfCredSaprResult">
        <include refid="selectSawfCredSaprVo"/>
        <where>
            <if test="unitName != null and unitName != ''">
                and unit_name like '%' || #{unitName} || '%'
            </if>
            <if test="unitSocCreCode != null and unitSocCreCode != ''">
                and unit_soc_cre_code = #{unitSocCreCode}
            </if>
        </where>
    </select>

    <insert id="insertSawfCredSapr" parameterType="com.goldenwater.slaj.sins.domain.SawfCredSapr">
        insert into sawf_cred_sapr (guid, unit_name, unit_soc_cre_code, black_list_start_date, black_list_end_date, black_list_rele_wiun, black_list_reas, note, coll_time, upd_time, rec_pers)
        values (#{guid}, #{unitName}, #{unitSocCreCode}, #{blackListStartDate}, #{blackListEndDate}, #{blackListReleWiun}, #{blackListReas}, #{note}, #{collTime}, #{updTime}, #{recPers})
    </insert>

    <update id="updateSawfCredSapr" parameterType="com.goldenwater.slaj.sins.domain.SawfCredSapr">
        update sawf_cred_sapr
        <set>
            <if test="unitName != null and unitName != ''">unit_name = #{unitName},</if>
            <if test="unitSocCreCode != null and unitSocCreCode != ''">unit_soc_cre_code = #{unitSocCreCode},</if>
            <if test="blackListStartDate != null">black_list_start_date = #{blackListStartDate},</if>
            <if test="blackListEndDate != null">black_list_end_date = #{blackListEndDate},</if>
            <if test="blackListReleWiun != null and blackListReleWiun != ''">black_list_rele_wiun = #{blackListReleWiun},</if>
            <if test="blackListReas != null and blackListReas != ''">black_list_reas = #{blackListReas},</if>
            <if test="note != null and note != ''">note = #{note},</if>
            <if test="collTime != null">coll_time = #{collTime},</if>
            <if test="updTime != null">upd_time = #{updTime},</if>
            <if test="recPers != null and recPers != ''">rec_pers = #{recPers},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteSawfCredSaprByGuid" parameterType="String">
        delete from sawf_cred_sapr where guid = #{guid}
    </delete>

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