This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhaoyixiang-realtime-protec…/src/main/resources/mappers/CommandMapper.xml

197 lines
8.7 KiB
XML
Raw Normal View History

<?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.realtime.protection.server.command.CommandMapper">
<insert id="createCommand" parameterType="com.realtime.protection.configuration.entity.task.TaskCommandInfo">
insert into t_command(COMMAND_ID, TASK_ID, TASK_ACT, TASKNAME, EVENTTYPE, DEPARTMENT, DISTRIBUTEPOINT, FREQUENCY,
ADDR_TYPE, SRC_IP, SRC_PORT, DST_IP, DST_PORT, PROTOCOL,
MASK_SRC_IP, MASK_SRC_PORT, MASK_DST_IP, MASK_DST_PORT, MASK_PROTOCOL, VALID_TIME,
INVALID_TIME, IS_VALID, IS_JUDGED,
SEND_TIMES, SUCCESS_TIMES, CREATE_TIME, LAST_UPDATE, IS_DELETED)
values (#{info.UUID}, #{info.taskId}, #{info.taskAct}, #{info.taskName}, #{info.eventType}, #{info.department}, #{info.distributePoint},
#{info.frequency},
DEFAULT,
#{info.fiveTupleWithMask.sourceIP}, #{info.fiveTupleWithMask.sourcePort},
#{info.fiveTupleWithMask.destinationIP}, #{info.fiveTupleWithMask.destinationPort},
#{info.fiveTupleWithMask.protocolNum},
#{info.fiveTupleWithMask.maskSourceIP}, #{info.fiveTupleWithMask.maskSourcePort},
#{info.fiveTupleWithMask.maskDestinationIP}, #{info.fiveTupleWithMask.maskDestinationPort},
#{info.fiveTupleWithMask.maskProtocol},
2024-01-22 23:40:48 +08:00
#{info.startTime}, #{info.endTime}, #{info.isValid},
#{info.isJudged},
0, 0,
NOW(), NOW(), FALSE)
</insert>
<insert id="createCommands" parameterType="com.realtime.protection.configuration.entity.task.TaskCommandInfo">
insert into t_command(
COMMAND_ID, TASK_ID, TASK_ACT, TASK_NAME, EVENT_TYPE, DEPARTMENT, DISTRIBUTEPOINT, FREQUENCY,
ADDR_TYPE, SRC_IP, SRC_PORT, DST_IP, DST_PORT, PROTOCOL,
2024-01-22 23:40:48 +08:00
MASK_SRC_IP, MASK_SRC_PORT, MASK_DST_IP, MASK_DST_PORT, MASK_PROTOCOL, VALID_TIME, INVALID_TIME, IS_VALID,
IS_JUDGED,
SEND_TIMES, SUCCESS_TIMES, CREATE_TIME, LAST_UPDATE, IS_DELETED)
values
<foreach collection="command_infos" item="info" separator=",">
(#{info.UUID}, #{info.taskId}, #{info.taskAct}, #{info.taskName}, #{info.eventType}, #{info.taskCreateDepart}, #{info.distributePoint},
#{info.frequency},
DEFAULT,
#{info.fiveTupleWithMask.sourceIP}, #{info.fiveTupleWithMask.sourcePort},
#{info.fiveTupleWithMask.destinationIP}, #{info.fiveTupleWithMask.destinationPort},
#{info.fiveTupleWithMask.protocolNum},
#{info.fiveTupleWithMask.maskSourceIP}, #{info.fiveTupleWithMask.maskSourcePort},
#{info.fiveTupleWithMask.maskDestinationIP}, #{info.fiveTupleWithMask.maskDestinationPort},
#{info.fiveTupleWithMask.maskProtocol},
2024-01-22 23:40:48 +08:00
#{info.startTime}, #{info.endTime}, #{info.isValid},
#{info.isJudged},
0, 0,
NOW(), NOW(), FALSE
)
</foreach>
</insert>
<resultMap id="commandStatMap" type="com.realtime.protection.configuration.entity.task.TaskCommandInfo">
<id column="COMMAND_ID" property="UUID"/>
<result column="TASK_ACT" property="taskAct"/>
<result column="SEND_TIMES" property="commandSentTimes"/>
<result column="SUCCESS_TIMES" property="commandSuccessTimes"/>
<result column="FIRST_SEND_TIME" property="earliestSendTime"/>
<result column="LAST_SEND_TIME" property="latestSendTime"/>
<association property="fiveTupleWithMask">
<result column="SRC_IP" property="sourceIP"/>
<result column="SRC_PORT" property="sourcePort"/>
<result column="DST_IP" property="destinationIP"/>
<result column="DST_PORT" property="destinationPort"/>
<result column="PROTOCOL" property="protocolNum"/>
</association>
</resultMap>
<select id="queryCommandInfoByUUID" resultMap="commandStatMap">
SELECT COMMAND_ID,
TASK_ACT,
SEND_TIMES,
SUCCESS_TIMES,
FIRST_SEND_TIME,
LASt_SEND_TIME,
SRC_IP,
SRC_PORT,
DST_IP,
DST_PORT,
PROTOCOL
FROM t_command
WHERE COMMAND_ID = #{uuid}
AND IS_DELETED = FALSE
</select>
<select id="queryCommandInfos" resultMap="commandStatMap">
SELECT COMMAND_ID,
TASK_ACT,
SEND_TIMES,
SUCCESS_TIMES,
FIRST_SEND_TIME,
LASt_SEND_TIME,
SRC_IP,
SRC_PORT,
DST_IP,
DST_PORT,
PROTOCOL
FROM t_command
<where>
AND TASK_ID = #{task_id}
AND IS_DELETED = FALSE
<if test="src_ip != null">AND SRC_IP = #{src_ip}</if>
<if test="dst_ip != null">AND DST_IP = #{dst_ip}</if>
<if test="src_port != null">AND SRC_PORT = #{src_port}</if>
<if test="dst_port != null">AND DST_PORT = #{dst_port}</if>
</where>
LIMIT ${(page-1) * page_num}, #{page_num}
</select>
<update id="stopCommandsByTaskId">
UPDATE t_command
2024-01-12 19:24:19 +08:00
SET IS_VALID = FALSE,
LAST_UPDATE = NOW()
WHERE TASK_ID = #{task_id}
AND IS_DELETED = FALSE
</update>
<update id="startCommandsByTaskId">
UPDATE t_command
2024-01-12 19:24:19 +08:00
SET IS_VALID = TRUE,
LAST_UPDATE = NOW()
WHERE TASK_ID = #{task_id}
AND IS_DELETED = FALSE
</update>
<update id="removeCommandsByTaskId">
UPDATE t_command
2024-01-12 19:24:19 +08:00
SET IS_DELETED = TRUE,
LAST_UPDATE = NOW()
WHERE TASK_ID = #{task_id}
AND IS_DELETED = FALSE
</update>
<update id="setCommandJudged">
UPDATE t_command
2024-01-22 23:40:48 +08:00
SET IS_JUDGED = #{is_judged},
LAST_UPDATE = NOW()
WHERE COMMAND_ID = #{command_id}
AND IS_DELETED = FALSE
</update>
<select id="queryCommandInfo" resultType="java.lang.String">
SELECT COMMAND_ID FROM t_command
<where>
2024-01-22 23:40:48 +08:00
<if test="command_info.taskId != null">
AND TASK_ID = #{command_info.taskId}
</if>
<if test="command_info.fiveTupleWithMask.addrType != null">
2024-01-22 23:40:48 +08:00
AND ADDR_TYPE = #{command_info.fiveTupleWithMask.addrType}
</if>
<if test="command_info.fiveTupleWithMask.sourceIP != null">
AND SRC_IP = #{command_info.fiveTupleWithMask.sourceIP}
</if>
<if test="command_info.fiveTupleWithMask.destinationIP != null">
AND DST_IP = #{command_info.fiveTupleWithMask.destinationIP}
</if>
<if test="command_info.fiveTupleWithMask.sourcePort != null">
AND SRC_PORT = #{command_info.fiveTupleWithMask.sourcePort}
</if>
<if test="command_info.fiveTupleWithMask.destinationPort != null">
AND DST_PORT = #{command_info.fiveTupleWithMask.destinationPort}
</if>
<if test="command_info.fiveTupleWithMask.protocol != null">
AND PROTOCOL = #{command_info.fiveTupleWithMask.protocol}
</if>
<if test="command_info.fiveTupleWithMask.maskSourceIP != null">
AND MASK_SRC_IP = #{command_info.fiveTupleWithMask.maskSourceIP}
</if>
<if test="command_info.fiveTupleWithMask.maskSourcePort != null">
2024-03-10 00:21:32 +08:00
AND MASK_SRC_PORT = #{command_info.fiveTupleWithMask.maskSourcePort}
</if>
<if test="command_info.fiveTupleWithMask.maskDestinationIP != null">
AND MASK_DST_IP = #{command_info.fiveTupleWithMask.maskDestinationIP}
</if>
<if test="command_info.fiveTupleWithMask.maskDestinationPort != null">
AND MASK_DST_PORT = #{command_info.fiveTupleWithMask.maskDestinationPort}
</if>
<if test="command_info.fiveTupleWithMask.maskProtocol != null">
AND MASK_PROTOCOL = #{command_info.fiveTupleWithMask.maskProtocol}
</if>
</where>
</select>
<select id="queryCommandTotalNum" resultType="java.lang.Integer">
SELECT COUNT(COMMAND_ID)
FROM t_command
<where>
AND TASK_ID = #{task_id}
AND IS_DELETED = FALSE
<if test="src_ip != null">AND SRC_IP = #{src_ip}</if>
<if test="dst_ip != null">AND DST_IP = #{dst_ip}</if>
<if test="src_port != null">AND SRC_PORT = #{src_port}</if>
<if test="dst_port != null">AND DST_PORT = #{dst_port}</if>
</where>
</select>
</mapper>