<?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.bd.mapper.BdFenceVioEvtMapper">

    <resultMap type="BdFenceVioEvt" id="BdFenceVioEvtResult">
        <result property="id" column="id"/>
        <result property="evtKey" column="evt_key"/>
        <result property="evtType" column="evt_type"/>
        <result property="evtDesc" column="evt_desc"/>
        <result property="lng" column="lng"/>
        <result property="lat" column="lat"/>
        <result property="fenceId" column="fence_id"/>
        <result property="evtStatus" column="evt_status"/>
        <result property="evtTime" column="evt_time"/>
        <result property="locationId" column="location_id"/>
        <result property="updateTime" column="update_time"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
    </resultMap>

    <sql id="selectBdFenceVioEvtVo">
        select id,
               evt_key,
               evt_type,
               evt_desc,
               lng,
               lat,
               fence_id,
               evt_status,
               evt_time,
               location_id,
               update_time,
               create_time,
               create_by,
               update_by
        from bd_fence_vio_evt
    </sql>

    <select id="selectBdFenceVioEvtList" parameterType="BdFenceVioEvt" resultMap="BdFenceVioEvtResult">
        <include refid="selectBdFenceVioEvtVo"/>
        <where>
            <if test="evtType != null  and evtType != ''">and evt_type = #{evtType}</if>
            <if test="evtDesc != null  and evtDesc != ''">and evt_desc = #{evtDesc}</if>
            <if test="evtStatus !=null and evtStatus!=''">and evt_status = #{evtStatus}</if>
            <if test="locationId !=null">and location_id = #{locationId}</if>
            <if test="evtTime !=null  and evtTime!=''">and evt_time >= #{evtTime}</if>
        </where>
        order by id desc
    </select>

    <select id="selectBdFenceVioEvtById" parameterType="Long" resultMap="BdFenceVioEvtResult">
        <include refid="selectBdFenceVioEvtVo"/>
        where id = #{id}
    </select>

    <insert id="insertBdFenceVioEvt" parameterType="BdFenceVioEvt" useGeneratedKeys="true" keyProperty="id">
        insert into bd_fence_vio_evt
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="evtKey != null">evt_key,</if>
            <if test="evtType != null">evt_type,</if>
            <if test="evtDesc != null">evt_desc,</if>
            <if test="lng != null">lng,</if>
            <if test="lat != null">lat,</if>
            <if test="fenceId != null">fence_id,</if>
            <if test="evtStatus !=null">evt_status,</if>
            <if test="evtTime !=null">evt_time,</if>
            <if test="locationId != null">location_id,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="evtKey != null">#{evtKey},</if>
            <if test="evtType != null">#{evtType},</if>
            <if test="evtDesc != null">#{evtDesc},</if>
            <if test="lng != null">#{lng},</if>
            <if test="lat != null">#{lat},</if>
            <if test="fenceId != null">#{fenceId},</if>
            <if test="evtStatus !=null">#{evtStatus},</if>
            <if test="evtTime !=null">#{evtTime},</if>
            <if test="locationId != null">#{locationId},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
        </trim>
    </insert>

    <update id="updateBdFenceVioEvt" parameterType="BdFenceVioEvt">
        update bd_fence_vio_evt
        <trim prefix="SET" suffixOverrides=",">
            <if test="evtKey != null">evt_key = #{evtKey},</if>
            <if test="evtType != null">evt_type = #{evtType},</if>
            <if test="evtDesc != null">evt_desc = #{evtDesc},</if>
            <if test="lng != null">lng = #{lng},</if>
            <if test="lat != null">lat = #{lat},</if>
            <if test="fenceId != null">fence_id = #{fenceId},</if>
            <if test="evtStatus !=null">evt_status = #{evtStatus},</if>
            <if test="evtTime !=null">evt_time = #{evtTime},</if>
            <if test="locationId != null">location_id = #{locationId},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBdFenceVioEvtById" parameterType="Long">
        delete
        from bd_fence_vio_evt
        where id = #{id}
    </delete>

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