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

    <resultMap type="RelPustBas" id="RelPustBasResult">
        <result property="pustCode" column="PUST_CODE"/>
        <result property="basCode" column="BAS_CODE"/>
        <result property="fromDate" column="FROM_DATE"/>
        <result property="toDate" column="TO_DATE"/>
    </resultMap>

    <sql id="selectRelPustBasVo">
        select PUST_CODE, BAS_CODE, FROM_DATE, TO_DATE from REL_PUST_BAS
    </sql>

    <select id="selectRelPustBasList" parameterType="RelPustBas" resultMap="RelPustBasResult">
        <include refid="selectRelPustBasVo"/>
        <where>
            <if test="pustCode != null and pustCode != ''">
                and PUST_CODE = #{pustCode}
            </if>
        </where>
        order by PUST_CODE
    </select>

    <select id="selectRelPustBasById" parameterType="RelPustBas" resultMap="RelPustBasResult">
        <include refid="selectRelPustBasVo"/>
        where PUST_CODE = #{pustCode} and BAS_CODE = #{basCode}
    </select>

    <delete id="deleteRelPustBasById" parameterType="RelPustBas">
        delete from REL_PUST_BAS where PUST_CODE = #{pustCode} and BAS_CODE = #{basCode}
    </delete>

    <insert id="insertRelPustBas" parameterType="RelPustBas">
        insert into REL_PUST_BAS
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pustCode != null">PUST_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="pustCode != null">#{pustCode},</if>
            <if test="basCode != null">#{basCode},</if>
            <if test="fromDate != null">#{fromDate},</if>
            <if test="toDate != null">#{toDate},</if>
        </trim>
    </insert>

    <update id="updateRelPustBas" parameterType="RelPustBas">
        update REL_PUST_BAS
        <trim prefix="SET" suffixOverrides=",">
            <if test="fromDate != null">FROM_DATE = #{fromDate},</if>
            <if test="toDate != null">TO_DATE = #{toDate},</if>
        </trim>
        where PUST_CODE = #{pustCode} and BAS_CODE = #{basCode}
    </update>

</mapper>
