<?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.RelSinsGroupToPersMapper">
    <resultMap type="com.goldenwater.slaj.sins.domain.RelSinsGroupToPers" id="RelSinsGroupToPersResult">
        <result property="guid" column="guid"/>
        <result property="groupGuid" column="group_guid"/>
        <result property="persGuid" column="pers_guid"/>
        <result property="fromDate" column="from_date"/>
        <result property="toDate" column="to_date"/>
    </resultMap>

    <sql id="selectRelSinsGroupToPersVo">
        select guid, group_guid, pers_guid, from_date, to_date from rel_sins_group_pers
    </sql>

    <select id="selectRelSinsGroupToPersByGuid" parameterType="String" resultMap="RelSinsGroupToPersResult">
        <include refid="selectRelSinsGroupToPersVo"/> where guid = #{guid}
    </select>

    <select id="selectRelSinsGroupToPersList" parameterType="com.goldenwater.slaj.sins.domain.RelSinsGroupToPers" resultMap="RelSinsGroupToPersResult">
        <include refid="selectRelSinsGroupToPersVo"/>
        <where>
            <if test="groupGuid != null and groupGuid != ''">
                and group_guid = #{groupGuid}
            </if>
            <if test="persGuid != null and persGuid != ''">
                and pers_guid = #{persGuid}
            </if>
        </where>
    </select>

    <insert id="insertRelSinsGroupToPers" parameterType="com.goldenwater.slaj.sins.domain.RelSinsGroupToPers">
        insert into rel_sins_group_pers (guid, group_guid, pers_guid, from_date, to_date)
        values (#{guid}, #{groupGuid}, #{persGuid}, #{fromDate}, #{toDate})
    </insert>

    <update id="updateRelSinsGroupToPers" parameterType="com.goldenwater.slaj.sins.domain.RelSinsGroupToPers">
        update rel_sins_group_pers
        <set>
            <if test="groupGuid != null and groupGuid != ''">group_guid = #{groupGuid},</if>
            <if test="persGuid != null and persGuid != ''">pers_guid = #{persGuid},</if>
            <if test="fromDate != null">from_date = #{fromDate},</if>
            <if test="toDate != null">to_date = #{toDate},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteRelSinsGroupToPersByGuid" parameterType="String">
        delete from rel_sins_group_pers where guid = #{guid}
    </delete>

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