Files
saas-houduan/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialSwitchInfoMapper.xml
T

265 lines
14 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.ruoyi.rocketmq.mapper.InitialSwitchInfoMapper">
<resultMap type="InitialSwitchInfo" id="InitialSwitchInfoResult">
2025-09-02 19:54:54 +08:00
<result property="id" column="id" />
<result property="clientId" column="client_id" />
<result property="name" column="name" />
<result property="inBytes" column="in_bytes" />
<result property="outBytes" column="out_bytes" />
<result property="status" column="status" />
<result property="type" column="type" />
<result property="inSpeed" column="in_speed" />
<result property="outSpeed" column="out_speed" />
<result property="switchIp" column="switch_ip" />
<result property="ifIndex" column="if_index" />
<result property="ifSpeed" column="if_speed" />
<result property="ifInDiscards" column="if_in_discards" />
<result property="ifOutDiscards" column="if_out_discards" />
<result property="ifInErrors" column="if_in_errors" />
<result property="ifOutErrors" column="if_out_errors" />
2025-09-02 19:54:54 +08:00
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectInitialSwitchInfoVo">
select id, client_id, name, in_bytes, out_bytes,
CASE
WHEN status = 1 THEN 'up'
WHEN status = 2 THEN 'down'
ELSE `status`
END AS status,
type, in_speed, out_speed, switch_ip, if_index,
if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors, create_by, update_by, create_time,
update_time from initial_switch_info
</sql>
2025-11-21 18:32:03 +08:00
<sql id="selectInitialSwitchInfoVoSharding">
select id, client_id, name, in_bytes, out_bytes,
CASE
WHEN status = 1 THEN 'up'
WHEN status = 2 THEN 'down'
ELSE `status`
END AS status,
type, in_speed, out_speed, switch_ip, if_index,
if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors, create_by, update_by, create_time,
update_time from ${tableName}
</sql>
<select id="selectInitialSwitchInfoList" parameterType="InitialSwitchInfo" resultMap="InitialSwitchInfoResult">
<include refid="selectInitialSwitchInfoVo"/>
<where>
2025-09-02 19:54:54 +08:00
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="name != null and name != ''"> and name = #{name}</if>
2025-09-02 19:54:54 +08:00
<if test="inBytes != null "> and in_bytes = #{inBytes}</if>
<if test="outBytes != null "> and out_bytes = #{outBytes}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="inSpeed != null "> and in_speed = #{inSpeed}</if>
<if test="outSpeed != null "> and out_speed = #{outSpeed}</if>
<if test="switchIp != null and switchIp != ''"> and switch_ip = #{switchIp}</if>
<if test="ifIndex != null and ifIndex != ''"> and if_index = #{ifIndex}</if>
<if test="ifSpeed != null "> and if_speed = #{ifSpeed}</if>
<if test="ifInDiscards != null "> and if_in_discards = #{ifInDiscards}</if>
<if test="ifOutDiscards != null "> and if_out_discards = #{ifOutDiscards}</if>
<if test="ifInErrors != null "> and if_in_errors = #{ifInErrors}</if>
<if test="ifOutErrors != null "> and if_out_errors = #{ifOutErrors}</if>
<if test="startTime != null and startTime != ''"> and create_time &gt;= #{startTime}</if>
<if test="endTime != null and endTime != ''"> and create_time &lt;= #{endTime}</if>
</where>
</select>
<select id="selectInitialSwitchInfoById" parameterType="Long" resultMap="InitialSwitchInfoResult">
<include refid="selectInitialSwitchInfoVo"/>
where id = #{id}
</select>
<insert id="insertInitialSwitchInfo" parameterType="InitialSwitchInfo" useGeneratedKeys="true" keyProperty="id">
2025-09-02 19:54:54 +08:00
insert into initial_switch_info
<trim prefix="(" suffix=")" suffixOverrides=",">
2025-09-02 19:54:54 +08:00
<if test="clientId != null and clientId != ''">client_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="inBytes != null">in_bytes,</if>
<if test="outBytes != null">out_bytes,</if>
<if test="status != null">status,</if>
<if test="type != null">type,</if>
<if test="inSpeed != null">in_speed,</if>
2025-09-02 19:54:54 +08:00
<if test="outSpeed != null">out_speed,</if>
<if test="switchIp != null and switchIp != ''">switch_ip,</if>
<if test="ifIndex != null and ifIndex != ''">if_index,</if>
<if test="ifSpeed != null">if_speed,</if>
<if test="ifInDiscards != null">if_in_discards,</if>
<if test="ifOutDiscards != null">if_out_discards,</if>
<if test="ifInErrors != null">if_in_errors,</if>
<if test="ifOutErrors != null">if_out_errors,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
2025-09-02 19:54:54 +08:00
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
2025-09-02 19:54:54 +08:00
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">#{clientId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="inBytes != null">#{inBytes},</if>
<if test="outBytes != null">#{outBytes},</if>
<if test="status != null">#{status},</if>
<if test="type != null">#{type},</if>
<if test="inSpeed != null">#{inSpeed},</if>
2025-09-02 19:54:54 +08:00
<if test="outSpeed != null">#{outSpeed},</if>
<if test="switchIp != null and switchIp != ''">#{switchIp},</if>
<if test="ifIndex != null and ifIndex != ''">#{ifIndex},</if>
<if test="ifSpeed != null">#{ifSpeed},</if>
<if test="ifInDiscards != null">#{ifInDiscards},</if>
<if test="ifOutDiscards != null">#{ifOutDiscards},</if>
<if test="ifInErrors != null">#{ifInErrors},</if>
<if test="ifOutErrors != null">#{ifOutErrors},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
2025-09-02 19:54:54 +08:00
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateInitialSwitchInfo" parameterType="InitialSwitchInfo">
2025-09-02 19:54:54 +08:00
update initial_switch_info
<trim prefix="SET" suffixOverrides=",">
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="inBytes != null">in_bytes = #{inBytes},</if>
<if test="outBytes != null">out_bytes = #{outBytes},</if>
<if test="status != null">status = #{status},</if>
<if test="type != null">type = #{type},</if>
2025-09-02 19:54:54 +08:00
<if test="inSpeed != null">in_speed = #{inSpeed},</if>
<if test="outSpeed != null">out_speed = #{outSpeed},</if>
<if test="switchIp != null and switchIp != ''">switch_ip = #{switchIp},</if>
<if test="ifIndex != null and ifIndex != ''">if_index = #{ifIndex},</if>
<if test="ifSpeed != null">if_speed = #{ifSpeed},</if>
<if test="ifInDiscards != null">if_in_discards = #{ifInDiscards},</if>
<if test="ifOutDiscards != null">if_out_discards = #{ifOutDiscards},</if>
<if test="ifInErrors != null">if_in_errors = #{ifInErrors},</if>
<if test="ifOutErrors != null">if_out_errors = #{ifOutErrors},</if>
2025-09-02 19:54:54 +08:00
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
2025-09-02 19:54:54 +08:00
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteInitialSwitchInfoById" parameterType="Long">
delete from initial_switch_info where id = #{id}
</delete>
<delete id="deleteInitialSwitchInfoByIds" parameterType="String">
delete from initial_switch_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsertInitialSwitchInfo" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
INSERT IGNORE INTO initial_switch_info
(
2025-09-02 19:54:54 +08:00
client_id, `name`, in_bytes, out_bytes, status, `type`, in_speed, out_speed, switch_ip,
if_index, if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors,
create_by, update_by, create_time, update_time
)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.clientId}, #{item.name}, #{item.inBytes}, #{item.outBytes},
#{item.status}, #{item.type}, #{item.inSpeed}, #{item.outSpeed}, #{item.switchIp},
#{item.ifIndex}, #{item.ifSpeed}, #{item.ifInDiscards},#{item.ifOutDiscards},#{item.ifInErrors},#{item.ifOutErrors},
#{item.createBy}, #{item.updateBy},
<choose>
<when test="item.createTime != null">
#{item.createTime}
</when>
<otherwise>
NOW()
</otherwise>
</choose>,
<choose>
<when test="item.updateTime != null">
#{item.updateTime}
</when>
<otherwise>
NOW()
</otherwise>
</choose>
)
</foreach>
</insert>
<select id="getSwitchNetDetailsMsg" parameterType="String" resultMap="InitialSwitchInfoResult">
<include refid="selectInitialSwitchInfoVo"/>
where client_id = #{clientId} and name = #{name}
limit 1
</select>
2025-11-21 18:32:03 +08:00
<select id="getSwitchNetDetailsMsgSharding" parameterType="String" resultMap="InitialSwitchInfoResult">
<include refid="selectInitialSwitchInfoVoSharding"/>
where client_id = #{clientId} and name = #{name}
order by create_time desc
limit 1
</select>
<insert id="batchInsertInitialSwitchInfoSharding" parameterType="InitialSwitchInfo">
INSERT IGNORE INTO ${tableName}
(
client_id, `name`, in_bytes, out_bytes, status, `type`, in_speed, out_speed, switch_ip,
if_index, if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors,
create_by, update_by, create_time, update_time
)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.clientId}, #{item.name}, #{item.inBytes}, #{item.outBytes},
#{item.status}, #{item.type}, #{item.inSpeed}, #{item.outSpeed}, #{item.switchIp},
#{item.ifIndex}, #{item.ifSpeed}, #{item.ifInDiscards},#{item.ifOutDiscards},#{item.ifInErrors},#{item.ifOutErrors},
#{item.createBy}, #{item.updateBy},
<choose>
<when test="item.createTime != null">
#{item.createTime}
</when>
<otherwise>
NOW()
</otherwise>
</choose>,
<choose>
<when test="item.updateTime != null">
#{item.updateTime}
</when>
<otherwise>
NOW()
</otherwise>
</choose>
)
</foreach>
</insert>
<select id="selectInitialSwitchInfoListSharding" parameterType="InitialSwitchInfo" resultMap="InitialSwitchInfoResult">
<include refid="selectInitialSwitchInfoVoSharding"/>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="name != null and name != ''"> and name = #{name}</if>
<if test="inBytes != null "> and in_bytes = #{inBytes}</if>
<if test="outBytes != null "> and out_bytes = #{outBytes}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="inSpeed != null "> and in_speed = #{inSpeed}</if>
<if test="outSpeed != null "> and out_speed = #{outSpeed}</if>
<if test="switchIp != null and switchIp != ''"> and switch_ip = #{switchIp}</if>
<if test="ifIndex != null and ifIndex != ''"> and if_index = #{ifIndex}</if>
<if test="ifSpeed != null "> and if_speed = #{ifSpeed}</if>
<if test="ifInDiscards != null "> and if_in_discards = #{ifInDiscards}</if>
<if test="ifOutDiscards != null "> and if_out_discards = #{ifOutDiscards}</if>
<if test="ifInErrors != null "> and if_in_errors = #{ifInErrors}</if>
<if test="ifOutErrors != null "> and if_out_errors = #{ifOutErrors}</if>
<if test="startTime != null and startTime != ''"> and create_time &gt;= #{startTime}</if>
<if test="endTime != null and endTime != ''"> and create_time &lt;= #{endTime}</if>
</where>
</select>
</mapper>