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

    <resultMap type="AttReaBase" id="AttReaBaseResult">
        <result property="reaCode" column="REA_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="reaName" column="REA_NAME"/>
        <result property="startLong" column="START_LONG"/>
        <result property="startLat" column="START_LAT"/>
        <result property="endLong" column="END_LONG"/>
        <result property="endLat" column="END_LAT"/>
        <result property="startLoc" column="START_LOC"/>
        <result property="endLoc" column="END_LOC"/>
        <result property="rvChanPatt" column="RV_CHAN_PATT"/>
        <result property="reaLen" column="REA_LEN"/>
        <result property="note" column="NOTE"/>
        <result property="updDate" column="UPD_DATE"/>
    </resultMap>

    <sql id="selectAttReaBaseVo">
        select REA_CODE, COLL_DATE, REA_NAME, START_LONG, START_LAT, END_LONG, END_LAT,
               START_LOC, END_LOC, RV_CHAN_PATT, REA_LEN, NOTE, UPD_DATE
        from ATT_REA_BASE
    </sql>

    <select id="selectAttReaBaseList" parameterType="AttReaBase" resultMap="AttReaBaseResult">
        <include refid="selectAttReaBaseVo"/>
        <where>
            <if test="reaName != null and reaName != ''">
                and REA_NAME like concat('%', #{reaName}, '%')
            </if>
            <if test="rvChanPatt != null and rvChanPatt != ''">
                and RV_CHAN_PATT = #{rvChanPatt}
            </if>
        </where>
        order by REA_CODE
    </select>

    <select id="selectAttReaBaseById" parameterType="String" resultMap="AttReaBaseResult">
        <include refid="selectAttReaBaseVo"/>
        where REA_CODE = #{reaCode}
    </select>

    <delete id="deleteAttReaBaseById" parameterType="String">
        delete from ATT_REA_BASE where REA_CODE = #{reaCode}
    </delete>

    <delete id="deleteAttReaBaseByIds" parameterType="String">
        delete from ATT_REA_BASE where REA_CODE in
        <foreach item="reaCode" collection="array" open="(" separator="," close=")">
            #{reaCode}
        </foreach>
    </delete>

    <insert id="insertAttReaBase" parameterType="AttReaBase">
        insert into ATT_REA_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="reaCode != null">REA_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="reaName != null">REA_NAME,</if>
            <if test="startLong != null">START_LONG,</if>
            <if test="startLat != null">START_LAT,</if>
            <if test="endLong != null">END_LONG,</if>
            <if test="endLat != null">END_LAT,</if>
            <if test="startLoc != null">START_LOC,</if>
            <if test="endLoc != null">END_LOC,</if>
            <if test="rvChanPatt != null">RV_CHAN_PATT,</if>
            <if test="reaLen != null">REA_LEN,</if>
            <if test="note != null">NOTE,</if>
            <if test="updDate != null">UPD_DATE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="reaCode != null">#{reaCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="reaName != null">#{reaName},</if>
            <if test="startLong != null">#{startLong},</if>
            <if test="startLat != null">#{startLat},</if>
            <if test="endLong != null">#{endLong},</if>
            <if test="endLat != null">#{endLat},</if>
            <if test="startLoc != null">#{startLoc},</if>
            <if test="endLoc != null">#{endLoc},</if>
            <if test="rvChanPatt != null">#{rvChanPatt},</if>
            <if test="reaLen != null">#{reaLen},</if>
            <if test="note != null">#{note},</if>
            <if test="updDate != null">#{updDate},</if>
        </trim>
    </insert>

    <update id="updateAttReaBase" parameterType="AttReaBase">
        update ATT_REA_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="reaName != null">REA_NAME = #{reaName},</if>
            <if test="startLong != null">START_LONG = #{startLong},</if>
            <if test="startLat != null">START_LAT = #{startLat},</if>
            <if test="endLong != null">END_LONG = #{endLong},</if>
            <if test="endLat != null">END_LAT = #{endLat},</if>
            <if test="startLoc != null">START_LOC = #{startLoc},</if>
            <if test="endLoc != null">END_LOC = #{endLoc},</if>
            <if test="rvChanPatt != null">RV_CHAN_PATT = #{rvChanPatt},</if>
            <if test="reaLen != null">REA_LEN = #{reaLen},</if>
            <if test="note != null">NOTE = #{note},</if>
            <if test="updDate != null">UPD_DATE = #{updDate},</if>
        </trim>
        where REA_CODE = #{reaCode}
    </update>

</mapper>
