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

103 lines
4.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, 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,
SEND_TIMES, SUCCESS_TIMES, CREATE_TIME, LAST_UPDATE, IS_DELETED)
values (UUID(), #{info.taskId}, #{info.taskAct}, #{info.frequency},
#{info.fiveTupleWithMask.addrType},
#{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},
#{info.startTime}, #{info.endTime}, TRUE, 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, 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,
SEND_TIMES, SUCCESS_TIMES, CREATE_TIME, LAST_UPDATE, IS_DELETED)
values
<foreach collection="command_infos" item="info" separator=",">
(UUID(), #{info.taskId}, #{info.taskAct}, #{info.frequency},
#{info.fiveTupleWithMask.addrType},
#{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},
#{info.startTime}, #{info.endTime}, TRUE, 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="queryCommandInfoByTaskId" 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 TASK_ID = #{task_id}
AND IS_DELETED = FALSE
</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>
</mapper>