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

    <resultMap type="AttLkBase" id="AttLkBaseResult">
        <result property="lkCode" column="LK_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="lkName" column="LK_NAME"/>
        <result property="lowLeftLong" column="LOW_LEFT_LONG"/>
        <result property="lowLeftLat" column="LOW_LEFT_LAT"/>
        <result property="upRightLong" column="UP_RIGHT_LONG"/>
        <result property="upRightLat" column="UP_RIGHT_LAT"/>
        <result property="crOverType" column="CR_OVER_TYPE"/>
        <result property="lkLoc" column="LK_LOC"/>
        <result property="meaAnnWatArea" column="MEA_ANN_WAT_AREA"/>
        <result property="meaAnnLkVol" column="MEA_ANN_LK_VOL"/>
        <result property="salFreWat" column="SAL_FRE_WAT"/>
        <result property="meaAnnWatDept" column="MEA_ANN_WAT_DEPT"/>
        <result property="maxDept" column="MAX_DEPT"/>
        <result property="note" column="NOTE"/>
        <result property="updDate" column="UPD_DATE"/>
    </resultMap>

    <sql id="selectAttLkBaseVo">
        select LK_CODE, COLL_DATE, LK_NAME, LOW_LEFT_LONG, LOW_LEFT_LAT, UP_RIGHT_LONG, UP_RIGHT_LAT,
               CR_OVER_TYPE, LK_LOC, MEA_ANN_WAT_AREA, MEA_ANN_LK_VOL, SAL_FRE_WAT,
               MEA_ANN_WAT_DEPT, MAX_DEPT, NOTE, UPD_DATE
        from ATT_LK_BASE
    </sql>

    <select id="selectAttLkBaseList" parameterType="AttLkBase" resultMap="AttLkBaseResult">
        <include refid="selectAttLkBaseVo"/>
        <where>
            <if test="lkName != null and lkName != ''">
                and LK_NAME like concat('%', #{lkName}, '%')
            </if>
            <if test="crOverType != null and crOverType != ''">
                and CR_OVER_TYPE = #{crOverType}
            </if>
            <if test="salFreWat != null and salFreWat != ''">
                and SAL_FRE_WAT = #{salFreWat}
            </if>
        </where>
        order by LK_CODE
    </select>

    <select id="selectAttLkBaseById" parameterType="String" resultMap="AttLkBaseResult">
        <include refid="selectAttLkBaseVo"/>
        where LK_CODE = #{lkCode}
    </select>

    <delete id="deleteAttLkBaseById" parameterType="String">
        delete from ATT_LK_BASE where LK_CODE = #{lkCode}
    </delete>

    <delete id="deleteAttLkBaseByIds" parameterType="String">
        delete from ATT_LK_BASE where LK_CODE in
        <foreach item="lkCode" collection="array" open="(" separator="," close=")">
            #{lkCode}
        </foreach>
    </delete>

    <insert id="insertAttLkBase" parameterType="AttLkBase">
        insert into ATT_LK_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="lkCode != null">LK_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="lkName != null">LK_NAME,</if>
            <if test="lowLeftLong != null">LOW_LEFT_LONG,</if>
            <if test="lowLeftLat != null">LOW_LEFT_LAT,</if>
            <if test="upRightLong != null">UP_RIGHT_LONG,</if>
            <if test="upRightLat != null">UP_RIGHT_LAT,</if>
            <if test="crOverType != null">CR_OVER_TYPE,</if>
            <if test="lkLoc != null">LK_LOC,</if>
            <if test="meaAnnWatArea != null">MEA_ANN_WAT_AREA,</if>
            <if test="meaAnnLkVol != null">MEA_ANN_LK_VOL,</if>
            <if test="salFreWat != null">SAL_FRE_WAT,</if>
            <if test="meaAnnWatDept != null">MEA_ANN_WAT_DEPT,</if>
            <if test="maxDept != null">MAX_DEPT,</if>
            <if test="note != null">NOTE,</if>
            <if test="updDate != null">UPD_DATE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="lkCode != null">#{lkCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="lkName != null">#{lkName},</if>
            <if test="lowLeftLong != null">#{lowLeftLong},</if>
            <if test="lowLeftLat != null">#{lowLeftLat},</if>
            <if test="upRightLong != null">#{upRightLong},</if>
            <if test="upRightLat != null">#{upRightLat},</if>
            <if test="crOverType != null">#{crOverType},</if>
            <if test="lkLoc != null">#{lkLoc},</if>
            <if test="meaAnnWatArea != null">#{meaAnnWatArea},</if>
            <if test="meaAnnLkVol != null">#{meaAnnLkVol},</if>
            <if test="salFreWat != null">#{salFreWat},</if>
            <if test="meaAnnWatDept != null">#{meaAnnWatDept},</if>
            <if test="maxDept != null">#{maxDept},</if>
            <if test="note != null">#{note},</if>
            <if test="updDate != null">#{updDate},</if>
        </trim>
    </insert>

    <update id="updateAttLkBase" parameterType="AttLkBase">
        update ATT_LK_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="lkName != null">LK_NAME = #{lkName},</if>
            <if test="lowLeftLong != null">LOW_LEFT_LONG = #{lowLeftLong},</if>
            <if test="lowLeftLat != null">LOW_LEFT_LAT = #{lowLeftLat},</if>
            <if test="upRightLong != null">UP_RIGHT_LONG = #{upRightLong},</if>
            <if test="upRightLat != null">UP_RIGHT_LAT = #{upRightLat},</if>
            <if test="crOverType != null">CR_OVER_TYPE = #{crOverType},</if>
            <if test="lkLoc != null">LK_LOC = #{lkLoc},</if>
            <if test="meaAnnWatArea != null">MEA_ANN_WAT_AREA = #{meaAnnWatArea},</if>
            <if test="meaAnnLkVol != null">MEA_ANN_LK_VOL = #{meaAnnLkVol},</if>
            <if test="salFreWat != null">SAL_FRE_WAT = #{salFreWat},</if>
            <if test="meaAnnWatDept != null">MEA_ANN_WAT_DEPT = #{meaAnnWatDept},</if>
            <if test="maxDept != null">MAX_DEPT = #{maxDept},</if>
            <if test="note != null">NOTE = #{note},</if>
            <if test="updDate != null">UPD_DATE = #{updDate},</if>
        </trim>
        where LK_CODE = #{lkCode}
    </update>

</mapper>
