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

    <resultMap type="RelResBas" id="RelResBasResult">
        <result property="resCode" column="RES_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="selectRelResBasVo">
        select RES_CODE, BAS_CODE, FROM_DATE, TO_DATE, SOURCE from REL_RES_BAS
    </sql>

    <select id="selectRelResBasList" parameterType="RelResBas" resultMap="RelResBasResult">
        <include refid="selectRelResBasVo"/>
        <where>
            <if test="resCode != null and resCode != ''">
                and RES_CODE = #{resCode}
            </if>
        </where>
        order by RES_CODE
    </select>

    <select id="selectRelResBasById" parameterType="RelResBas" resultMap="RelResBasResult">
        <include refid="selectRelResBasVo"/>
        where RES_CODE = #{resCode} and BAS_CODE = #{basCode}
    </select>

    <delete id="deleteRelResBasById" parameterType="RelResBas">
        delete from REL_RES_BAS where RES_CODE = #{resCode} and BAS_CODE = #{basCode}
    </delete>

    <insert id="insertRelResBas" parameterType="RelResBas">
        insert into REL_RES_BAS
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="resCode != null">RES_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="resCode != null">#{resCode},</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="updateRelResBas" parameterType="RelResBas">
        update REL_RES_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 RES_CODE = #{resCode} and BAS_CODE = #{basCode}
    </update>

</mapper>
