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

    <resultMap type="TElectronicFenceService" id="TElectronicFenceServiceResult">
        <result property="id" column="id"/>
        <result property="keyId" column="key_id"/>
        <result property="amapSid" column="amap_sid"/>
        <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="selectTElectronicFenceServiceVo">
        select id, key_id, amap_sid, create_time, update_time, amap_name, amap_desc
        from t_electronic_fence_service
    </sql>

    <select id="selectTElectronicFenceServiceList" parameterType="TElectronicFenceService"
            resultMap="TElectronicFenceServiceResult">
        <include refid="selectTElectronicFenceServiceVo"/>
        <where>
            <if test="keyId != null ">and key_id = #{keyId}</if>
            <if test="amapSid != null  and amapSid != ''">and amap_sid = #{amapSid}</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="selectTElectronicFenceServiceById" parameterType="Long" resultMap="TElectronicFenceServiceResult">
        <include refid="selectTElectronicFenceServiceVo"/>
        where id = #{id}
    </select>

    <select id="selectTElectronicFenceServiceByKeyId" resultMap="TElectronicFenceServiceResult">
        <include refid="selectTElectronicFenceServiceVo"/>
        where key_id = #{key_id}
    </select>

    <insert id="insertTElectronicFenceService" parameterType="TElectronicFenceService" useGeneratedKeys="true"
            keyProperty="id">
        insert into t_electronic_fence_service
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="keyId != null">key_id,</if>
            <if test="amapSid != null and amapSid != ''">amap_sid,</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="keyId != null">#{keyId},</if>
            <if test="amapSid != null and amapSid != ''">#{amapSid},</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="updateTElectronicFenceService" parameterType="TElectronicFenceService">
        update t_electronic_fence_service
        <trim prefix="SET" suffixOverrides=",">
            <if test="keyId != null">key_id = #{keyId},</if>
            <if test="amapSid != null and amapSid != ''">amap_sid = #{amapSid},</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="deleteTElectronicFenceServiceById" parameterType="Long">
        delete
        from t_electronic_fence_service
        where id = #{id}
    </delete>

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