<?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.acci.mapper.SawfSafeSupeMapper">
    <resultMap type="com.goldenwater.slaj.acci.domain.SawfSafeSupe" id="SawfSafeSupeResult">
        <result property="guid" column="guid"/>
        <result property="socCreCode" column="soc_cre_code"/>
        <result property="enteName" column="ente_name"/>
        <result property="offiAddr" column="offi_addr"/>
        <result property="enteType" column="ente_type"/>
        <result property="legPers" column="leg_pers"/>
        <result property="contTel" column="cont_tel"/>
        <result property="safeProdLiceNum" column="safe_prod_lice_num"/>
        <result property="certiStartDate" column="certi_start_date"/>
        <result property="certiEndDate" column="certi_end_date"/>
        <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="selectSawfSafeSupeVo">
        select guid, soc_cre_code, ente_name, offi_addr, ente_type, leg_pers,
               cont_tel, safe_prod_lice_num, certi_start_date, certi_end_date,
               note, coll_time, upd_time, rec_pers
        from sawf_safe_supe
    </sql>
    <select id="selectSawfSafeSupeByGuid" parameterType="String" resultMap="SawfSafeSupeResult">
        <include refid="selectSawfSafeSupeVo"/>
        where guid = #{guid}
    </select>
    <select id="selectSawfSafeSupeList" parameterType="com.goldenwater.slaj.acci.domain.SawfSafeSupe" resultMap="SawfSafeSupeResult">
        <include refid="selectSawfSafeSupeVo"/>
        <where>
            <if test="guid != null and guid != ''">AND guid = #{guid}</if>
            <if test="socCreCode != null and socCreCode != ''">AND soc_cre_code = #{socCreCode}</if>
            <if test="enteName != null and enteName != ''">AND ente_name like '%' || #{enteName} || '%'</if>
            <if test="enteType != null and enteType != ''">AND ente_type = #{enteType}</if>
            <if test="legPers != null and legPers != ''">AND leg_pers like '%' || #{legPers} || '%'</if>
        </where>
    </select>
    <insert id="insertSawfSafeSupe" parameterType="com.goldenwater.slaj.acci.domain.SawfSafeSupe">
        insert into sawf_safe_supe (
            guid, soc_cre_code, ente_name, offi_addr, ente_type, leg_pers,
            cont_tel, safe_prod_lice_num, certi_start_date, certi_end_date,
            note, coll_time, upd_time, rec_pers
        ) values (
            #{guid}, #{socCreCode}, #{enteName}, #{offiAddr}, #{enteType}, #{legPers},
            #{contTel}, #{safeProdLiceNum}, #{certiStartDate}, #{certiEndDate},
            #{note}, #{collTime}, #{updTime}, #{recPers}
        )
    </insert>
    <update id="updateSawfSafeSupe" parameterType="com.goldenwater.slaj.acci.domain.SawfSafeSupe">
        update sawf_safe_supe
        <set>
            <if test="socCreCode != null">soc_cre_code = #{socCreCode},</if>
            <if test="enteName != null">ente_name = #{enteName},</if>
            <if test="offiAddr != null">offi_addr = #{offiAddr},</if>
            <if test="enteType != null">ente_type = #{enteType},</if>
            <if test="legPers != null">leg_pers = #{legPers},</if>
            <if test="contTel != null">cont_tel = #{contTel},</if>
            <if test="safeProdLiceNum != null">safe_prod_lice_num = #{safeProdLiceNum},</if>
            <if test="certiStartDate != null">certi_start_date = #{certiStartDate},</if>
            <if test="certiEndDate != null">certi_end_date = #{certiEndDate},</if>
            <if test="note != null">note = #{note},</if>
            <if test="collTime != null">coll_time = #{collTime},</if>
            <if test="updTime != null">upd_time = #{updTime},</if>
            <if test="recPers != null">rec_pers = #{recPers},</if>
        </set>
        where guid = #{guid}
    </update>
    <delete id="deleteSawfSafeSupeByGuid" parameterType="String">
        delete from sawf_safe_supe where guid = #{guid}
    </delete>
    <delete id="deleteSawfSafeSupeByGuids" parameterType="String">
        delete from sawf_safe_supe where guid in
        <foreach item="guid" collection="array" open="(" separator="," close=")">
            #{guid}
        </foreach>
    </delete>
</mapper>
