<?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.slgc.mapper.RelDikeBasMapper">

    <resultMap type="RelDikeBas" id="RelDikeBasResult">
        <result property="dikeCode" column="DIKE_CODE"/>
        <result property="basCode" column="BAS_CODE"/>
        <result property="fromDate" column="FROM_DATE"/>
        <result property="toDate" column="TO_DATE"/>
    </resultMap>

    <sql id="selectRelDikeBasVo">
        select DIKE_CODE, BAS_CODE, FROM_DATE, TO_DATE from REL_DIKE_BAS
    </sql>

    <select id="selectRelDikeBasList" parameterType="RelDikeBas" resultMap="RelDikeBasResult">
        <include refid="selectRelDikeBasVo"/>
        <where>
            <if test="dikeCode != null and dikeCode != ''">
                and DIKE_CODE = #{dikeCode}
            </if>
        </where>
        order by DIKE_CODE
    </select>

    <select id="selectRelDikeBasById" parameterType="RelDikeBas" resultMap="RelDikeBasResult">
        <include refid="selectRelDikeBasVo"/>
        where DIKE_CODE = #{dikeCode} and BAS_CODE = #{basCode}
    </select>

    <delete id="deleteRelDikeBasById" parameterType="RelDikeBas">
        delete from REL_DIKE_BAS where DIKE_CODE = #{dikeCode} and BAS_CODE = #{basCode}
    </delete>

    <insert id="insertRelDikeBas" parameterType="RelDikeBas">
        insert into REL_DIKE_BAS
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dikeCode != null">DIKE_CODE,</if>
            <if test="basCode != null">BAS_CODE,</if>
            <if test="fromDate != null">FROM_DATE,</if>
            <if test="toDate != null">TO_DATE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dikeCode != null">#{dikeCode},</if>
            <if test="basCode != null">#{basCode},</if>
            <if test="fromDate != null">#{fromDate},</if>
            <if test="toDate != null">#{toDate},</if>
        </trim>
    </insert>

    <update id="updateRelDikeBas" parameterType="RelDikeBas">
        update REL_DIKE_BAS
        <trim prefix="SET" suffixOverrides=",">
            <if test="fromDate != null">FROM_DATE = #{fromDate},</if>
            <if test="toDate != null">TO_DATE = #{toDate},</if>
        </trim>
        where DIKE_CODE = #{dikeCode} and BAS_CODE = #{basCode}
    </update>

</mapper>
