<?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.zongzhi.mapper.TcSafetyDetectionMapper">
    
    <resultMap type="TcSafetyDetection" id="TcSafetyDetectionResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="attackTime"    column="attack_time"    />
        <result property="sourceIp"    column="source_ip"    />
        <result property="attackedLongitude"    column="attacked_longitude"    />
        <result property="attackedLatitude"    column="attacked_latitude"    />
        <result property="attackType"    column="attack_type"    />
        <result property="attackIpRegion"    column="attack_ip_region"    />
        <result property="attackedIp"    column="attacked_ip"    />
        <result property="attackedIpRegion"    column="attacked_ip_region"    />
        <result property="attackLongitude"    column="attack_longitude"    />
        <result property="attackLatitude"    column="attack_latitude"    />
        <result property="level"    column="level"    />
        <result property="affUnit"    column="aff_unit"    />
        <result property="phoneNum"    column="phone_num"    />
        <result property="linkMan"    column="link_man"    />
        <result property="createId"    column="create_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateId"    column="update_id"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTcSafetyDetectionVo">
        select id, area_id, attack_time, source_ip, attacked_longitude, attacked_latitude, attack_type, attack_ip_region, attacked_ip, attacked_ip_region, attack_longitude, attack_latitude, level, aff_unit, phone_num, link_man, create_id, create_by, create_time, update_id, update_by, update_time, remark from tc_safety_detection
    </sql>

    <select id="selectTcSafetyDetectionList" parameterType="TcSafetyDetection" resultMap="TcSafetyDetectionResult">
        <include refid="selectTcSafetyDetectionVo"/>
        <where>  
            <if test="areaId != null "> and area_id = #{areaId}</if>
            <if test="attackTime != null "> and attack_time = #{attackTime}</if>
            <if test="sourceIp != null  and sourceIp != ''"> and source_ip = #{sourceIp}</if>
            <if test="attackedLongitude != null  and attackedLongitude != ''"> and attacked_longitude = #{attackedLongitude}</if>
            <if test="attackedLatitude != null  and attackedLatitude != ''"> and attacked_latitude = #{attackedLatitude}</if>
            <if test="attackType != null "> and attack_type = #{attackType}</if>
            <if test="attackIpRegion != null  and attackIpRegion != ''"> and attack_ip_region = #{attackIpRegion}</if>
            <if test="attackedIp != null  and attackedIp != ''"> and attacked_ip = #{attackedIp}</if>
            <if test="attackedIpRegion != null  and attackedIpRegion != ''"> and attacked_ip_region = #{attackedIpRegion}</if>
            <if test="attackLongitude != null  and attackLongitude != ''"> and attack_longitude = #{attackLongitude}</if>
            <if test="attackLatitude != null  and attackLatitude != ''"> and attack_latitude = #{attackLatitude}</if>
            <if test="level != null "> and level = #{level}</if>
            <if test="affUnit != null  and affUnit != ''"> and aff_unit = #{affUnit}</if>
            <if test="phoneNum != null  and phoneNum != ''"> and phone_num = #{phoneNum}</if>
            <if test="linkMan != null  and linkMan != ''"> and link_man = #{linkMan}</if>
            <if test="createId != null "> and create_id = #{createId}</if>
            <if test="updateId != null "> and update_id = #{updateId}</if>
        </where>
    </select>
    
    <select id="selectTcSafetyDetectionById" parameterType="Long" resultMap="TcSafetyDetectionResult">
        <include refid="selectTcSafetyDetectionVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcSafetyDetection" parameterType="TcSafetyDetection" useGeneratedKeys="true" keyProperty="id">
        insert into tc_safety_detection
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="attackTime != null">attack_time,</if>
            <if test="sourceIp != null">source_ip,</if>
            <if test="attackedLongitude != null">attacked_longitude,</if>
            <if test="attackedLatitude != null">attacked_latitude,</if>
            <if test="attackType != null">attack_type,</if>
            <if test="attackIpRegion != null">attack_ip_region,</if>
            <if test="attackedIp != null">attacked_ip,</if>
            <if test="attackedIpRegion != null">attacked_ip_region,</if>
            <if test="attackLongitude != null">attack_longitude,</if>
            <if test="attackLatitude != null">attack_latitude,</if>
            <if test="level != null">level,</if>
            <if test="affUnit != null">aff_unit,</if>
            <if test="phoneNum != null">phone_num,</if>
            <if test="linkMan != null">link_man,</if>
            <if test="createId != null">create_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateId != null">update_id,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="areaId != null">#{areaId},</if>
            <if test="attackTime != null">#{attackTime},</if>
            <if test="sourceIp != null">#{sourceIp},</if>
            <if test="attackedLongitude != null">#{attackedLongitude},</if>
            <if test="attackedLatitude != null">#{attackedLatitude},</if>
            <if test="attackType != null">#{attackType},</if>
            <if test="attackIpRegion != null">#{attackIpRegion},</if>
            <if test="attackedIp != null">#{attackedIp},</if>
            <if test="attackedIpRegion != null">#{attackedIpRegion},</if>
            <if test="attackLongitude != null">#{attackLongitude},</if>
            <if test="attackLatitude != null">#{attackLatitude},</if>
            <if test="level != null">#{level},</if>
            <if test="affUnit != null">#{affUnit},</if>
            <if test="phoneNum != null">#{phoneNum},</if>
            <if test="linkMan != null">#{linkMan},</if>
            <if test="createId != null">#{createId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateId != null">#{updateId},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTcSafetyDetection" parameterType="TcSafetyDetection">
        update tc_safety_detection
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="attackTime != null">attack_time = #{attackTime},</if>
            <if test="sourceIp != null">source_ip = #{sourceIp},</if>
            <if test="attackedLongitude != null">attacked_longitude = #{attackedLongitude},</if>
            <if test="attackedLatitude != null">attacked_latitude = #{attackedLatitude},</if>
            <if test="attackType != null">attack_type = #{attackType},</if>
            <if test="attackIpRegion != null">attack_ip_region = #{attackIpRegion},</if>
            <if test="attackedIp != null">attacked_ip = #{attackedIp},</if>
            <if test="attackedIpRegion != null">attacked_ip_region = #{attackedIpRegion},</if>
            <if test="attackLongitude != null">attack_longitude = #{attackLongitude},</if>
            <if test="attackLatitude != null">attack_latitude = #{attackLatitude},</if>
            <if test="level != null">level = #{level},</if>
            <if test="affUnit != null">aff_unit = #{affUnit},</if>
            <if test="phoneNum != null">phone_num = #{phoneNum},</if>
            <if test="linkMan != null">link_man = #{linkMan},</if>
            <if test="createId != null">create_id = #{createId},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateId != null">update_id = #{updateId},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTcSafetyDetectionById" parameterType="Long">
        delete from tc_safety_detection where id = #{id}
    </delete>

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