<?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.RelEngOrgMapper">
    <resultMap type="com.goldenwater.slaj.sins.domain.RelEngOrg" id="RelEngOrgResult">
        <result property="guid" column="guid"/>
        <result property="engGuid" column="eng_guid"/>
        <result property="orgGuid" column="org_guid"/>
        <result property="fromDate" column="from_date"/>
        <result property="toDate" column="to_date"/>
    </resultMap>

    <sql id="selectRelEngOrgVo">
        select guid, eng_guid, org_guid, from_date, to_date from rel_eng_org
    </sql>

    <select id="selectRelEngOrgByGuid" parameterType="String" resultMap="RelEngOrgResult">
        <include refid="selectRelEngOrgVo"/> where guid = #{guid}
    </select>

    <select id="selectRelEngOrgList" parameterType="com.goldenwater.slaj.sins.domain.RelEngOrg" resultMap="RelEngOrgResult">
        <include refid="selectRelEngOrgVo"/>
        <where>
            <if test="engGuid != null and engGuid != ''">
                and eng_guid = #{engGuid}
            </if>
            <if test="orgGuid != null and orgGuid != ''">
                and org_guid = #{orgGuid}
            </if>
        </where>
    </select>

    <insert id="insertRelEngOrg" parameterType="com.goldenwater.slaj.sins.domain.RelEngOrg">
        insert into rel_eng_org (guid, eng_guid, org_guid, from_date, to_date)
        values (#{guid}, #{engGuid}, #{orgGuid}, #{fromDate}, #{toDate})
    </insert>

    <update id="updateRelEngOrg" parameterType="com.goldenwater.slaj.sins.domain.RelEngOrg">
        update rel_eng_org
        <set>
            <if test="engGuid != null and engGuid != ''">eng_guid = #{engGuid},</if>
            <if test="orgGuid != null and orgGuid != ''">org_guid = #{orgGuid},</if>
            <if test="fromDate != null">from_date = #{fromDate},</if>
            <if test="toDate != null">to_date = #{toDate},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteRelEngOrgByGuid" parameterType="String">
        delete from rel_eng_org where guid = #{guid}
    </delete>

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