<?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.RelWagaBasMapper">

    <resultMap type="RelWagaBas" id="RelWagaBasResult">
        <result property="wagaCode" column="WAGA_CODE"/>
        <result property="basCode" column="BAS_CODE"/>
        <result property="fromDate" column="FROM_DATE"/>
        <result property="toDate" column="TO_DATE"/>
        <result property="source" column="SOURCE"/>
    </resultMap>

    <sql id="selectRelWagaBasVo">
        select WAGA_CODE, BAS_CODE, FROM_DATE, TO_DATE, SOURCE from REL_WAGA_BAS
    </sql>

    <select id="selectRelWagaBasList" parameterType="RelWagaBas" resultMap="RelWagaBasResult">
        <include refid="selectRelWagaBasVo"/>
        <where>
            <if test="wagaCode != null and wagaCode != ''">
                and WAGA_CODE = #{wagaCode}
            </if>
        </where>
        order by WAGA_CODE
    </select>

    <select id="selectRelWagaBasById" parameterType="RelWagaBas" resultMap="RelWagaBasResult">
        <include refid="selectRelWagaBasVo"/>
        where WAGA_CODE = #{wagaCode} and BAS_CODE = #{basCode}
    </select>

    <delete id="deleteRelWagaBasById" parameterType="RelWagaBas">
        delete from REL_WAGA_BAS where WAGA_CODE = #{wagaCode} and BAS_CODE = #{basCode}
    </delete>

    <insert id="insertRelWagaBas" parameterType="RelWagaBas">
        insert into REL_WAGA_BAS
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="wagaCode != null">WAGA_CODE,</if>
            <if test="basCode != null">BAS_CODE,</if>
            <if test="fromDate != null">FROM_DATE,</if>
            <if test="toDate != null">TO_DATE,</if>
            <if test="source != null">SOURCE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="wagaCode != null">#{wagaCode},</if>
            <if test="basCode != null">#{basCode},</if>
            <if test="fromDate != null">#{fromDate},</if>
            <if test="toDate != null">#{toDate},</if>
            <if test="source != null">#{source},</if>
        </trim>
    </insert>

    <update id="updateRelWagaBas" parameterType="RelWagaBas">
        update REL_WAGA_BAS
        <trim prefix="SET" suffixOverrides=",">
            <if test="fromDate != null">FROM_DATE = #{fromDate},</if>
            <if test="toDate != null">TO_DATE = #{toDate},</if>
            <if test="source != null">SOURCE = #{source},</if>
        </trim>
        where WAGA_CODE = #{wagaCode} and BAS_CODE = #{basCode}
    </update>

</mapper>
