2024-01-05 09:32:19 +08:00
|
|
|
<?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.defense.object.ProtectObjectMapper">
|
2024-01-05 21:42:19 +08:00
|
|
|
<insert id="newProtectObject"
|
|
|
|
|
parameterType="com.realtime.protection.configuration.entity.defense.object.ProtectObject"
|
|
|
|
|
useGeneratedKeys="true" keyProperty="protectObjectId">
|
|
|
|
|
INSERT INTO t_protect_object(protect_object_id, protect_object_name, protect_object_system_name,
|
|
|
|
|
protect_object_ip, protect_object_port, protect_object_url,
|
|
|
|
|
protect_object_protocol,
|
|
|
|
|
protect_object_create_username, protect_object_create_depart,
|
2024-04-29 15:33:09 +08:00
|
|
|
protect_object_create_user_id, protect_object_display_id)
|
2024-01-05 21:42:19 +08:00
|
|
|
VALUE (#{proobj.protectObjectId}, #{proobj.protectObjectName}, #{proobj.protectObjectSystemName},
|
|
|
|
|
INET_ATON(#{proobj.protectObjectIPAddress}), #{proobj.protectObjectPort}, #{proobj.protectObjectURL},
|
|
|
|
|
#{proobj.protectObjectProtocol},
|
|
|
|
|
#{proobj.protectObjectCreateUsername}, #{proobj.protectObjectCreateDepart},
|
2024-04-29 15:33:09 +08:00
|
|
|
#{proobj.protectObjectCreateUserId}, #{proobj.protectObjectDisplayId})
|
2024-01-05 21:42:19 +08:00
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<insert id="newProtectObjects" parameterType="List">
|
|
|
|
|
INSERT INTO t_protect_object(protect_object_id, protect_object_name, protect_object_system_name,
|
2024-01-12 19:24:19 +08:00
|
|
|
protect_object_ip, protect_object_port, protect_object_url,
|
|
|
|
|
protect_object_protocol,
|
|
|
|
|
protect_object_create_username, protect_object_create_depart,
|
2024-04-29 15:33:09 +08:00
|
|
|
protect_object_create_user_id, protect_object_display_id)
|
2024-01-12 19:24:19 +08:00
|
|
|
VALUES
|
|
|
|
|
<foreach collection="proobjs" item="proobj" separator=",">
|
|
|
|
|
(#{proobj.protectObjectId}, #{proobj.protectObjectName}, #{proobj.protectObjectSystemName},
|
|
|
|
|
INET_ATON(#{proobj.protectObjectIPAddress}), #{proobj.protectObjectPort}, #{proobj.protectObjectURL},
|
|
|
|
|
#{proobj.protectObjectProtocol},
|
|
|
|
|
#{proobj.protectObjectCreateUsername}, #{proobj.protectObjectCreateDepart},
|
2024-04-29 15:33:09 +08:00
|
|
|
#{proobj.protectObjectCreateUserId}, #{proobj.protectObjectDisplayId})
|
2024-01-12 19:24:19 +08:00
|
|
|
</foreach>
|
2024-01-05 21:42:19 +08:00
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<resultMap id="protectObjectMap" type="com.realtime.protection.configuration.entity.defense.object.ProtectObject">
|
|
|
|
|
<id column="protect_object_id" property="protectObjectId"/>
|
|
|
|
|
<result column="protect_object_name" property="protectObjectName"/>
|
|
|
|
|
<result column="protect_object_system_name" property="protectObjectSystemName"/>
|
|
|
|
|
<result column="protect_object_ip" property="protectObjectIPAddress"/>
|
|
|
|
|
<result column="protect_object_port" property="protectObjectPort"/>
|
|
|
|
|
<result column="protect_object_url" property="protectObjectURL"/>
|
|
|
|
|
<result column="protect_object_protocol" property="protectObjectProtocol"/>
|
|
|
|
|
<result column="protect_object_audit_status" property="protectObjectAuditStatus"/>
|
2024-05-08 10:41:47 +08:00
|
|
|
<result column="protect_object_display_id" property="protectObjectDisplayId"/>
|
|
|
|
|
|
2024-01-05 21:42:19 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<select id="queryProtectObjects" resultMap="protectObjectMap">
|
2024-01-15 20:40:55 +08:00
|
|
|
SELECT
|
2024-04-23 12:15:07 +08:00
|
|
|
protect_object_id, protect_object_name, protect_object_system_name,
|
|
|
|
|
INET_NTOA(protect_object_ip) as protect_object_ip,
|
2024-01-15 20:40:55 +08:00
|
|
|
protect_object_port, protect_object_url, protect_object_protocol, protect_object_audit_status
|
2024-05-08 10:41:47 +08:00
|
|
|
,protect_object_display_id
|
2024-01-15 20:40:55 +08:00
|
|
|
FROM t_protect_object
|
2024-01-05 21:42:19 +08:00
|
|
|
<where>
|
2024-05-09 16:39:52 +08:00
|
|
|
<if test="proobj_name != null and proobj_name != '' ">AND protect_object_name LIKE CONCAT('%', #{proobj_name}, '%')</if>
|
2024-01-31 18:28:25 +08:00
|
|
|
<if test="proobj_id != null">AND protect_object_id = #{proobj_id}</if>
|
2024-05-09 16:39:52 +08:00
|
|
|
<if test="proobj_system_name != null and proobj_system_name != '' ">
|
2024-01-31 18:28:25 +08:00
|
|
|
AND protect_object_system_name LIKE CONCAT('%', #{proobj_system_name}, '%')
|
|
|
|
|
</if>
|
2024-05-09 16:39:52 +08:00
|
|
|
<if test="proobj_ip != null and proobj_ip != '' ">
|
2024-01-31 18:28:25 +08:00
|
|
|
AND protect_object_id IN (
|
2024-05-09 16:39:52 +08:00
|
|
|
SELECT protect_object_id FROM t_protect_object_inet_addr_view tpo_view
|
|
|
|
|
WHERE tpo_view.protect_object_ip LIKE CONCAT('%', #{proobj_ip}, '%')
|
2024-01-31 18:28:25 +08:00
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proobj_port_min != null">
|
2024-05-09 16:39:52 +08:00
|
|
|
AND protect_object_port >= #{proobj_port_min}
|
2024-01-31 18:28:25 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="proobj_port_max != null">
|
2024-05-09 16:39:52 +08:00
|
|
|
AND protect_object_port <= #{proobj_port_max}
|
2024-01-31 18:28:25 +08:00
|
|
|
</if>
|
2024-05-09 16:39:52 +08:00
|
|
|
<if test="proobj_url != null and proobj_url != '' ">
|
2024-01-31 18:28:25 +08:00
|
|
|
AND protect_object_url LIKE CONCAT('%', #{proobj_url}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proobj_protocol != null">
|
|
|
|
|
AND protect_object_protocol = #{proobj_protocol}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proobj_username != null">
|
|
|
|
|
AND protect_object_create_username = #{proobj_username}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proobj_audit_status != null">
|
|
|
|
|
AND protect_object_audit_status = #{proobj_audit_status}
|
|
|
|
|
</if>
|
2024-01-05 21:42:19 +08:00
|
|
|
</where>
|
|
|
|
|
LIMIT ${(page-1) * page_size}, #{page_size}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="queryProtectObject" resultMap="protectObjectMap">
|
2024-01-15 20:40:55 +08:00
|
|
|
SELECT protect_object_id,
|
|
|
|
|
protect_object_name,
|
|
|
|
|
protect_object_system_name,
|
|
|
|
|
INET_NTOA(protect_object_ip),
|
|
|
|
|
protect_object_port,
|
|
|
|
|
protect_object_url,
|
|
|
|
|
protect_object_protocol,
|
2024-05-08 10:41:47 +08:00
|
|
|
protect_object_audit_status,protect_object_display_id
|
2024-01-12 19:24:19 +08:00
|
|
|
FROM t_protect_object
|
2024-01-05 21:42:19 +08:00
|
|
|
WHERE protect_object_id = #{proobj_id}
|
|
|
|
|
</select>
|
2024-01-31 18:28:25 +08:00
|
|
|
|
2024-01-23 12:17:10 +08:00
|
|
|
<select id="queryProtectObjectsTotalNum" resultType="java.lang.Integer">
|
|
|
|
|
SELECT COUNT(protect_object_id) FROM t_protect_object
|
|
|
|
|
<where>
|
2024-05-09 15:40:33 +08:00
|
|
|
<if test="proobj_name != null and proobj_name != '' ">AND protect_object_name LIKE CONCAT('%', #{proobj_name}, '%')</if>
|
2024-01-31 18:28:25 +08:00
|
|
|
<if test="proobj_id != null">AND protect_object_id = #{proobj_id}</if>
|
2024-05-09 15:40:33 +08:00
|
|
|
<if test="proobj_system_name != null and proobj_system_name != '' ">
|
2024-01-31 18:28:25 +08:00
|
|
|
AND protect_object_system_name LIKE CONCAT('%', #{proobj_system_name}, '%')
|
|
|
|
|
</if>
|
2024-05-09 15:40:33 +08:00
|
|
|
<if test="proobj_ip != null and proobj_ip != '' ">
|
2024-01-31 18:28:25 +08:00
|
|
|
AND protect_object_id IN (
|
|
|
|
|
SELECT protect_object_id FROM t_protect_object_inet_addr_view tpo_view
|
|
|
|
|
WHERE tpo_view.protect_object_ip LIKE CONCAT('%', #{proobj_ip}, '%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proobj_port_min != null">
|
|
|
|
|
AND protect_object_port >= #{proobj_port_min}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proobj_port_max != null">
|
|
|
|
|
AND protect_object_port <= #{proobj_port_max}
|
|
|
|
|
</if>
|
2024-05-09 15:40:33 +08:00
|
|
|
<if test="proobj_url != null and proobj_url != '' ">
|
2024-01-31 18:28:25 +08:00
|
|
|
AND protect_object_url LIKE CONCAT('%', #{proobj_url}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proobj_protocol != null">
|
|
|
|
|
AND protect_object_protocol = #{proobj_protocol}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proobj_username != null">
|
|
|
|
|
AND protect_object_create_username = #{proobj_username}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proobj_audit_status != null">
|
|
|
|
|
AND protect_object_audit_status = #{proobj_audit_status}
|
|
|
|
|
</if>
|
2024-01-23 12:17:10 +08:00
|
|
|
</where>
|
|
|
|
|
</select>
|
2024-04-25 01:41:28 +08:00
|
|
|
<select id="queryUsedProtectObjectsTotalNum"
|
|
|
|
|
resultType="java.lang.Integer">
|
|
|
|
|
SELECT COUNT(DISTINCT protect_object_id)
|
|
|
|
|
FROM t_protect_object_dynamic_rule_conn
|
|
|
|
|
</select>
|
2024-01-05 21:42:19 +08:00
|
|
|
|
2024-05-09 13:06:21 +08:00
|
|
|
<select id="queryAuditStatusByIds" resultType="java.lang.Integer">
|
|
|
|
|
select protect_object_audit_status
|
|
|
|
|
from t_protect_object
|
|
|
|
|
where protect_object_id in
|
|
|
|
|
<foreach collection="idsWithAuditStatusMap" index="id" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</select>
|
|
|
|
|
|
2024-01-05 21:42:19 +08:00
|
|
|
<update id="updateProtectObject">
|
|
|
|
|
UPDATE t_protect_object
|
|
|
|
|
<set>
|
|
|
|
|
<if test="proobj.protectObjectName != null">protect_object_name = #{proobj.protectObjectName},</if>
|
|
|
|
|
<if test="proobj.protectObjectSystemName != null">
|
|
|
|
|
protect_object_system_name = #{proobj.protectObjectSystemName},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proobj.protectObjectIPAddress">protect_object_ip = INET_ATON(#{proobj.protectObjectIPAddress}),
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proobj.protectObjectPort">protect_object_port = #{proobj.protectObjectPort},</if>
|
|
|
|
|
<if test="proobj.protectObjectURL">protect_object_url = #{proobj.protectObjectURL},</if>
|
|
|
|
|
<if test="proobj.protectObjectProtocol">protect_object_protocol = #{proobj.protectObjectProtocol},</if>
|
2024-01-08 20:01:20 +08:00
|
|
|
modify_time = NOW()
|
2024-01-05 21:42:19 +08:00
|
|
|
</set>
|
|
|
|
|
<where>
|
|
|
|
|
<if test="proobj.protectObjectId != null">protect_object_id = #{proobj.protectObjectId}</if>
|
|
|
|
|
</where>
|
|
|
|
|
</update>
|
|
|
|
|
|
2024-01-05 09:32:19 +08:00
|
|
|
<delete id="deleteProtectObject">
|
2024-01-12 19:24:19 +08:00
|
|
|
DELETE
|
|
|
|
|
FROM t_protect_object
|
2024-01-05 09:32:19 +08:00
|
|
|
WHERE protect_object_id = #{proobj_id}
|
|
|
|
|
</delete>
|
2024-01-05 21:42:19 +08:00
|
|
|
|
|
|
|
|
<delete id="deleteProtectObjects">
|
|
|
|
|
DELETE FROM t_protect_object
|
|
|
|
|
WHERE protect_object_id IN
|
|
|
|
|
<foreach collection="proobj_ids" item="proobj_id" separator="," open="(" close=")">
|
|
|
|
|
#{proobj_id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<update id="changeProtectObjectAuditStatus">
|
|
|
|
|
UPDATE t_protect_object
|
|
|
|
|
SET protect_object_audit_status = #{proobj_audit_status}
|
|
|
|
|
WHERE protect_object_id = #{proobj_id}
|
|
|
|
|
</update>
|
2024-05-09 13:06:21 +08:00
|
|
|
|
|
|
|
|
<update id="updateAuditStatusByIdBatch">
|
|
|
|
|
update t_protect_object
|
|
|
|
|
set protect_object_audit_status = CASE protect_object_id
|
|
|
|
|
<foreach collection="idWithAuditStatusBatch" index="id" item="auditStatus" separator=" ">
|
|
|
|
|
WHEN #{id} THEN #{auditStatus}
|
|
|
|
|
</foreach>
|
|
|
|
|
END
|
|
|
|
|
WHERE protect_object_id IN
|
|
|
|
|
<foreach collection="idWithAuditStatusBatch" index="id" open="(" separator="," close=")">
|
|
|
|
|
#{id}
|
|
|
|
|
</foreach>
|
|
|
|
|
</update>
|
2024-01-05 09:32:19 +08:00
|
|
|
</mapper>
|