<?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.RelSinsToOrgMapper">
    <resultMap type="com.goldenwater.slaj.sins.domain.RelSinsToOrg" id="RelSinsToOrgResult">
        <result property="guid" column="guid"/>
        <result property="sinsGuid" column="sins_guid"/>
        <result property="orgGuid" column="org_guid"/>
        <result property="fromDate" column="from_date"/>
        <result property="toDate" column="to_date"/>
        <result property="stat" column="stat"/>
    </resultMap>

    <sql id="selectRelSinsToOrgVo">
        select guid, sins_guid, org_guid, from_date, to_date, stat from rel_sins_org
    </sql>

    <select id="selectRelSinsToOrgByGuid" parameterType="String" resultMap="RelSinsToOrgResult">
        <include refid="selectRelSinsToOrgVo"/> where guid = #{guid}
    </select>

    <select id="selectRelSinsToOrgList" parameterType="com.goldenwater.slaj.sins.domain.RelSinsToOrg" resultMap="RelSinsToOrgResult">
        <include refid="selectRelSinsToOrgVo"/>
        <where>
            <if test="sinsGuid != null and sinsGuid != ''">
                and sins_guid = #{sinsGuid}
            </if>
            <if test="orgGuid != null and orgGuid != ''">
                and org_guid = #{orgGuid}
            </if>
        </where>
    </select>

    <insert id="insertRelSinsToOrg" parameterType="com.goldenwater.slaj.sins.domain.RelSinsToOrg">
        insert into rel_sins_org (guid, sins_guid, org_guid, from_date, to_date, stat)
        values (#{guid}, #{sinsGuid}, #{orgGuid}, #{fromDate}, #{toDate}, #{stat})
    </insert>

    <update id="updateRelSinsToOrg" parameterType="com.goldenwater.slaj.sins.domain.RelSinsToOrg">
        update rel_sins_org
        <set>
            <if test="sinsGuid != null and sinsGuid != ''">sins_guid = #{sinsGuid},</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>
            <if test="stat != null and stat != ''">stat = #{stat},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteRelSinsToOrgByGuid" parameterType="String">
        delete from rel_sins_org where guid = #{guid}
    </delete>

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