<?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.RelSinsGroupToExpeMapper">
    <resultMap type="com.goldenwater.slaj.sins.domain.RelSinsGroupToExpe" id="RelSinsGroupToExpeResult">
        <result property="guid" column="guid"/>
        <result property="groupGuid" column="group_guid"/>
        <result property="expeGuid" column="expe_guid"/>
        <result property="fromDate" column="from_date"/>
        <result property="toDate" column="to_date"/>
    </resultMap>

    <sql id="selectRelSinsGroupToExpeVo">
        select guid, group_guid, expe_guid, from_date, to_date from rel_sins_group_expe
    </sql>

    <select id="selectRelSinsGroupToExpeByGuid" parameterType="String" resultMap="RelSinsGroupToExpeResult">
        <include refid="selectRelSinsGroupToExpeVo"/> where guid = #{guid}
    </select>

    <select id="selectRelSinsGroupToExpeList" parameterType="com.goldenwater.slaj.sins.domain.RelSinsGroupToExpe" resultMap="RelSinsGroupToExpeResult">
        <include refid="selectRelSinsGroupToExpeVo"/>
        <where>
            <if test="groupGuid != null and groupGuid != ''">
                and group_guid = #{groupGuid}
            </if>
            <if test="expeGuid != null and expeGuid != ''">
                and expe_guid = #{expeGuid}
            </if>
        </where>
    </select>

    <insert id="insertRelSinsGroupToExpe" parameterType="com.goldenwater.slaj.sins.domain.RelSinsGroupToExpe">
        insert into rel_sins_group_expe (guid, group_guid, expe_guid, from_date, to_date)
        values (#{guid}, #{groupGuid}, #{expeGuid}, #{fromDate}, #{toDate})
    </insert>

    <update id="updateRelSinsGroupToExpe" parameterType="com.goldenwater.slaj.sins.domain.RelSinsGroupToExpe">
        update rel_sins_group_expe
        <set>
            <if test="groupGuid != null and groupGuid != ''">group_guid = #{groupGuid},</if>
            <if test="expeGuid != null and expeGuid != ''">expe_guid = #{expeGuid},</if>
            <if test="fromDate != null">from_date = #{fromDate},</if>
            <if test="toDate != null">to_date = #{toDate},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteRelSinsGroupToExpeByGuid" parameterType="String">
        delete from rel_sins_group_expe where guid = #{guid}
    </delete>

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