<?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.tcZz.mapper.TcWljgMapper">
    
    <resultMap type="TcWljg" id="TcWljgResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="isStatus"    column="isStatus"    />
        <result property="startTime"    column="start_time"    />
        <result property="attackyIp"    column="attacky_ip"    />
        <result property="attackType"    column="attack_type"    />
        <result property="attackIpArea"    column="attack_ip_area"    />
        <result property="type"    column="type"    />
        <result property="sAttackIp"    column="s_attack_ip"    />
        <result property="sAttackIpArea"    column="s_attack_ip_area"    />
        <result property="netLevel"    column="net_level"    />
        <result property="affUnit"    column="aff_unit"    />
        <result property="linkTel"    column="link_tel"    />
        <result property="linkMan"    column="link_man"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTcWljgVo">
        select id, area_id, isStatus, start_time, attacky_ip, attack_type, attack_ip_area, type, s_attack_ip, s_attack_ip_area, net_level, aff_unit, link_tel, link_man, create_by, create_time, update_by, update_time, remark from tc_wljg
    </sql>

    <select id="selectTcWljgList" parameterType="TcWljg" resultMap="TcWljgResult">
        <include refid="selectTcWljgVo"/>
        <where>
            <if test="id != null ">and id = #{id}</if>
            <if test="areaId != null and areaId != ''">and area_id = #{areaId}</if>
            <if test="isStatus != null ">and isStatus = #{isStatus}</if>
            <if test="params.beginStartTime != null and params.beginStartTime != '' and params.endStartTime != null and params.endStartTime != ''">
                and start_time between #{params.beginStartTime} and #{params.endStartTime}
            </if>
            <if test="attackyIp != null and attackyIp != ''">and attacky_ip = #{attackyIp}</if>
            <if test="attackType != null and attackType != ''">and attack_type = #{attackType}</if>
            <if test="attackIpArea != null and attackIpArea != ''">and attack_ip_area = #{attackIpArea}</if>
            <if test="type != null and type != ''">and type = #{type}</if>
            <if test="sAttackIp != null and sAttackIp != ''">and s_attack_ip = #{sAttackIp}</if>
            <if test="sAttackIpArea != null and sAttackIpArea != ''">and s_attack_ip_area = #{sAttackIpArea}</if>
            <if test="netLevel != null and netLevel != ''">and net_level = #{netLevel}</if>
            <if test="affUnit != null and affUnit != ''">and aff_unit = #{affUnit}</if>
            <if test="linkTel != null and linkTel != ''">and link_tel = #{linkTel}</if>
            <if test="linkMan != null and linkMan != ''">and link_man = #{linkMan}</if>
            <if test="createBy != null and createBy != ''">and create_by = #{createBy}</if>
            <if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
                and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
            </if>
            <if test="updateBy != null and updateBy != ''">and update_by = #{updateBy}</if>
            <if test="params.beginUpdateTime != null and params.beginUpdateTime != '' and params.endUpdateTime != null and params.endUpdateTime != ''">
                and update_time between #{params.beginUpdateTime} and #{params.endUpdateTime}
            </if>
            <if test="remark != null and remark != ''">and remark = #{remark}</if>
        </where>
        order by  start_time desc
    </select>
    
    <select id="selectTcWljgById" parameterType="Long" resultMap="TcWljgResult">
        <include refid="selectTcWljgVo"/>
        where id = #{id}
    </select>


    <insert id="insertTcWljg" parameterType="TcWljg" useGeneratedKeys="true" keyProperty="id">
        insert into tc_wljg
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="isStatus != null">isStatus,</if>
            <if test="startTime != null">start_time,</if>
            <if test="attackyIp != null">attacky_ip,</if>
            <if test="attackType != null">attack_type,</if>
            <if test="attackIpArea != null">attack_ip_area,</if>
            <if test="type != null">type,</if>
            <if test="sAttackIp != null">s_attack_ip,</if>
            <if test="sAttackIpArea != null">s_attack_ip_area,</if>
            <if test="netLevel != null">net_level,</if>
            <if test="affUnit != null">aff_unit,</if>
            <if test="linkTel != null">link_tel,</if>
            <if test="linkMan != null">link_man,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</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="isStatus != null">#{isStatus},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="attackyIp != null">#{attackyIp},</if>
            <if test="attackType != null">#{attackType},</if>
            <if test="attackIpArea != null">#{attackIpArea},</if>
            <if test="type != null">#{type},</if>
            <if test="sAttackIp != null">#{sAttackIp},</if>
            <if test="sAttackIpArea != null">#{sAttackIpArea},</if>
            <if test="netLevel != null">#{netLevel},</if>
            <if test="affUnit != null">#{affUnit},</if>
            <if test="linkTel != null">#{linkTel},</if>
            <if test="linkMan != null">#{linkMan},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTcWljg" parameterType="TcWljg">
        update tc_wljg
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="isStatus != null">isStatus = #{isStatus},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="attackyIp != null">attacky_ip = #{attackyIp},</if>
            <if test="attackType != null">attack_type = #{attackType},</if>
            <if test="attackIpArea != null">attack_ip_area = #{attackIpArea},</if>
            <if test="type != null">type = #{type},</if>
            <if test="sAttackIp != null">s_attack_ip = #{sAttackIp},</if>
            <if test="sAttackIpArea != null">s_attack_ip_area = #{sAttackIpArea},</if>
            <if test="netLevel != null">net_level = #{netLevel},</if>
            <if test="affUnit != null">aff_unit = #{affUnit},</if>
            <if test="linkTel != null">link_tel = #{linkTel},</if>
            <if test="linkMan != null">link_man = #{linkMan},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</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>
    <update id="updateByisStatus">
        UPDATE tc_wljg
        SET isStatus = #{isStatus}
        WHERE id IN
        <foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
            #{item}
        </foreach>
    </update>

    <delete id="deleteTcWljgById" parameterType="Long">
        delete from tc_wljg where id = #{id}
    </delete>

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