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

    <resultMap type="ObjDike" id="ObjDikeResult">
        <result property="dikeCode" column="DIKE_CODE"/>
        <result property="dikeName" column="DIKE_NAME"/>
        <result property="fromDate" column="FROM_DATE"/>
        <result property="toDate" column="TO_DATE"/>
    </resultMap>

    <sql id="selectObjDikeVo">
        select DIKE_CODE, DIKE_NAME, FROM_DATE, TO_DATE from OBJ_DIKE
    </sql>

    <select id="selectObjDikeList" parameterType="ObjDike" resultMap="ObjDikeResult">
        <include refid="selectObjDikeVo"/>
        <where>
            <if test="dikeName != null and dikeName != ''">
                and DIKE_NAME like concat('%', #{dikeName}, '%')
            </if>
        </where>
        order by DIKE_CODE
    </select>

    <select id="selectObjDikeById" parameterType="String" resultMap="ObjDikeResult">
        <include refid="selectObjDikeVo"/>
        where DIKE_CODE = #{dikeCode}
    </select>

    <delete id="deleteObjDikeById" parameterType="String">
        delete from OBJ_DIKE where DIKE_CODE = #{dikeCode}
    </delete>

    <insert id="insertObjDike" parameterType="ObjDike">
        insert into OBJ_DIKE
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dikeCode != null">DIKE_CODE,</if>
            <if test="dikeName != null">DIKE_NAME,</if>
            <if test="fromDate != null">FROM_DATE,</if>
            <if test="toDate != null">TO_DATE,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dikeCode != null">#{dikeCode},</if>
            <if test="dikeName != null">#{dikeName},</if>
            <if test="fromDate != null">#{fromDate},</if>
            <if test="toDate != null">#{toDate},</if>
        </trim>
    </insert>

    <update id="updateObjDike" parameterType="ObjDike">
        update OBJ_DIKE
        <trim prefix="SET" suffixOverrides=",">
            <if test="dikeName != null">DIKE_NAME = #{dikeName},</if>
            <if test="fromDate != null">FROM_DATE = #{fromDate},</if>
            <if test="toDate != null">TO_DATE = #{toDate},</if>
        </trim>
        where DIKE_CODE = #{dikeCode}
    </update>

</mapper>
