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

    <resultMap type="AttDiscBase" id="AttDiscBaseResult">
        <result property="discCode" column="DISC_CODE"/>
        <result property="collDate" column="COLL_DATE"/>
        <result property="discName" column="DISC_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="discGrad" column="DISC_GRAD"/>
        <result property="discType" column="DISC_TYPE"/>
        <result property="discPatt" column="DISC_PATT"/>
        <result property="discLen" column="DISC_LEN"/>
        <result property="note" column="NOTE"/>
        <result property="updDate" column="UPD_DATE"/>
    </resultMap>

    <sql id="selectAttDiscBaseVo">
        select DISC_CODE, COLL_DATE, DISC_NAME, START_LONG, START_LAT, END_LONG, END_LAT,
               START_LOC, END_LOC, DISC_GRAD, DISC_TYPE, DISC_PATT, DISC_LEN, NOTE, UPD_DATE
        from ATT_DISC_BASE
    </sql>

    <select id="selectAttDiscBaseList" parameterType="AttDiscBase" resultMap="AttDiscBaseResult">
        <include refid="selectAttDiscBaseVo"/>
        <where>
            <if test="discName != null and discName != ''">
                and DISC_NAME like concat('%', #{discName}, '%')
            </if>
            <if test="discGrad != null and discGrad != ''">
                and DISC_GRAD = #{discGrad}
            </if>
            <if test="discType != null and discType != ''">
                and DISC_TYPE = #{discType}
            </if>
            <if test="discPatt != null and discPatt != ''">
                and DISC_PATT = #{discPatt}
            </if>
        </where>
        order by DISC_CODE
    </select>

    <select id="selectAttDiscBaseById" parameterType="String" resultMap="AttDiscBaseResult">
        <include refid="selectAttDiscBaseVo"/>
        where DISC_CODE = #{discCode}
    </select>

    <delete id="deleteAttDiscBaseById" parameterType="String">
        delete from ATT_DISC_BASE where DISC_CODE = #{discCode}
    </delete>

    <delete id="deleteAttDiscBaseByIds" parameterType="String">
        delete from ATT_DISC_BASE where DISC_CODE in
        <foreach item="discCode" collection="array" open="(" separator="," close=")">
            #{discCode}
        </foreach>
    </delete>

    <insert id="insertAttDiscBase" parameterType="AttDiscBase">
        insert into ATT_DISC_BASE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="discCode != null">DISC_CODE,</if>
            <if test="collDate != null">COLL_DATE,</if>
            <if test="discName != null">DISC_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="discGrad != null">DISC_GRAD,</if>
            <if test="discType != null">DISC_TYPE,</if>
            <if test="discPatt != null">DISC_PATT,</if>
            <if test="discLen != null">DISC_LEN,</if>
            <if test="note != null">NOTE,</if>
            <if test="updDate != null">UPD_DATE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="discCode != null">#{discCode},</if>
            <if test="collDate != null">#{collDate},</if>
            <if test="discName != null">#{discName},</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="discGrad != null">#{discGrad},</if>
            <if test="discType != null">#{discType},</if>
            <if test="discPatt != null">#{discPatt},</if>
            <if test="discLen != null">#{discLen},</if>
            <if test="note != null">#{note},</if>
            <if test="updDate != null">#{updDate},</if>
        </trim>
    </insert>

    <update id="updateAttDiscBase" parameterType="AttDiscBase">
        update ATT_DISC_BASE
        <trim prefix="SET" suffixOverrides=",">
            <if test="collDate != null">COLL_DATE = #{collDate},</if>
            <if test="discName != null">DISC_NAME = #{discName},</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="discGrad != null">DISC_GRAD = #{discGrad},</if>
            <if test="discType != null">DISC_TYPE = #{discType},</if>
            <if test="discPatt != null">DISC_PATT = #{discPatt},</if>
            <if test="discLen != null">DISC_LEN = #{discLen},</if>
            <if test="note != null">NOTE = #{note},</if>
            <if test="updDate != null">UPD_DATE = #{updDate},</if>
        </trim>
        where DISC_CODE = #{discCode}
    </update>

</mapper>
