<?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.ruoyi.system.mapper.TElectronicFenceKeyMapper">

    <resultMap type="TElectronicFenceKey" id="TElectronicFenceKeyResult">
        <result property="id" column="id"/>
        <result property="amapKey" column="amap_key"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="amapName" column="amap_name"/>
        <result property="amapDesc" column="amap_desc"/>
    </resultMap>

    <sql id="selectTElectronicFenceKeyVo">
        select id, amap_key, create_time, update_time, amap_name, amap_desc
        from t_electronic_fence_key
    </sql>

    <select id="selectTElectronicFenceKeyList" parameterType="TElectronicFenceKey"
            resultMap="TElectronicFenceKeyResult">
        <include refid="selectTElectronicFenceKeyVo"/>
        <where>
            <if test="amapKey != null  and amapKey != ''">and amap_key = #{amapKey}</if>
            <if test="amapName != null  and amapName != ''">and amap_name like concat('%', #{amapName}, '%')</if>
            <if test="amapDesc != null  and amapDesc != ''">and amap_desc = #{amapDesc}</if>
        </where>
    </select>

    <select id="selectTElectronicFenceKeyById" parameterType="Long" resultMap="TElectronicFenceKeyResult">
        <include refid="selectTElectronicFenceKeyVo"/>
        where id = #{id}
    </select>

    <select id="selectTElectronicFenceKey" resultMap="TElectronicFenceKeyResult">
        <include refid="selectTElectronicFenceKeyVo"/>
    </select>

    <insert id="insertTElectronicFenceKey" parameterType="TElectronicFenceKey" useGeneratedKeys="true" keyProperty="id">
        insert into t_electronic_fence_key
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="amapKey != null and amapKey != ''">amap_key,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="amapName != null">amap_name,</if>
            <if test="amapDesc != null">amap_desc,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="amapKey != null and amapKey != ''">#{amapKey},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="amapName != null">#{amapName},</if>
            <if test="amapDesc != null">#{amapDesc},</if>
        </trim>
    </insert>

    <update id="updateTElectronicFenceKey" parameterType="TElectronicFenceKey">
        update t_electronic_fence_key
        <trim prefix="SET" suffixOverrides=",">
            <if test="amapKey != null and amapKey != ''">amap_key = #{amapKey},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="amapName != null">amap_name = #{amapName},</if>
            <if test="amapDesc != null">amap_desc = #{amapDesc},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTElectronicFenceKeyById" parameterType="Long">
        delete
        from t_electronic_fence_key
        where id = #{id}
    </delete>

    <delete id="deleteTElectronicFenceKeyByIds" parameterType="String">
        delete from t_electronic_fence_key where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>