磁盘表分表,增加磁盘名称存储CRUD

This commit is contained in:
gaoyutao
2026-01-15 10:27:40 +08:00
parent ac406d88fe
commit c921a83d27
18 changed files with 788 additions and 31 deletions
@@ -0,0 +1,119 @@
<?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.tongran.rocketmq.mapper.AllDiskNameMapper">
<resultMap type="AllDiskName" id="AllDiskNameResult">
<result property="id" column="id" />
<result property="clientId" column="client_id" />
<result property="name" column="name" />
<result property="status" column="status" />
<result property="readIops" column="read_iops" />
<result property="writeIops" column="write_iops" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectAllDiskNameVo">
select id, client_id, name, status, read_iops, write_iops, create_time, update_time, create_by, update_by from all_disk_name
</sql>
<select id="selectAllDiskNameList" parameterType="AllDiskName" resultMap="AllDiskNameResult">
<include refid="selectAllDiskNameVo"/>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="name != null and name != ''"> and name = #{name}</if>
<if test="status != null "> and status = #{status}</if>
<if test="readIops != null and readIops != ''"> and read_iops = #{readIops}</if>
<if test="writeIops != null and writeIops != ''"> and write_iops = #{writeIops}</if>
</where>
</select>
<select id="selectAllDiskNameById" parameterType="Long" resultMap="AllDiskNameResult">
<include refid="selectAllDiskNameVo"/>
where id = #{id}
</select>
<insert id="insertAllDiskName" parameterType="AllDiskName" useGeneratedKeys="true" keyProperty="id">
insert into all_disk_name
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">client_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="status != null">status,</if>
<if test="readIops != null">read_iops,</if>
<if test="writeIops != null">write_iops,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">#{clientId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="status != null">#{status},</if>
<if test="readIops != null">#{readIops},</if>
<if test="writeIops != null">#{writeIops},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="status != null">status = #{status},</if>
<if test="readIops != null">read_iops = #{readIops},</if>
<if test="writeIops != null">write_iops = #{writeIops},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
</insert>
<update id="updateAllDiskName" parameterType="AllDiskName">
update all_disk_name
<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="status != null">status = #{status},</if>
<if test="readIops != null">read_iops = #{readIops},</if>
<if test="writeIops != null">write_iops = #{writeIops},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAllDiskNameById" parameterType="Long">
delete from all_disk_name where id = #{id}
</delete>
<delete id="deleteAllDiskNameByIds" parameterType="String">
delete from all_disk_name where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsertAllDistName" parameterType="java.util.List">
insert IGNORE into all_disk_name
(client_id, name, status, read_iops, write_iops, create_time, update_time, create_by, update_by)
values
<foreach collection="list" item="item" separator=",">
(
#{item.clientId},
#{item.name},
#{item.status},
#{item.readIops},
#{item.writeIops},
#{item.createTime},
#{item.updateTime},
#{item.createBy},
#{item.updateBy}
)
</foreach>
</insert>
</mapper>
@@ -1,9 +1,9 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tongran.rocketmq.mapper.InitialDiskInfoMapper">
<resultMap type="InitialDiskInfo" id="InitialDiskInfoResult">
<result property="id" column="id" />
<result property="clientId" column="client_id" />
@@ -16,6 +16,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="readTimes" column="read_times" />
<result property="writeBytes" column="write_bytes" />
<result property="readBytes" column="read_bytes" />
<!-- 新增的两个字段 -->
<result property="type" column="type" />
<result property="usedSpace" column="used_space" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="createTime" column="create_time" />
@@ -23,20 +26,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectInitialDiskInfoVo">
select id, client_id, name, serial, total, write_speed, read_speed, write_times, read_times, write_bytes, read_bytes, create_by, update_by, create_time, update_time from initial_disk_info
select id, client_id, name, serial, total, write_speed, read_speed, write_times, read_times, write_bytes, read_bytes, type, used_space, create_by, update_by, create_time, update_time from initial_disk_info
</sql>
<select id="selectInitialDiskInfoList" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
<include refid="selectInitialDiskInfoVo"/>
<where>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="name != null and name != ''"> and name = #{name}</if>
<if test="type != null and type != ''"> and type = #{type}</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>
order by create_time desc
</select>
<select id="selectInitialDiskInfoListByCondition" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
select id, client_id, name, serial, total, write_speed, read_speed, write_times, read_times, write_bytes,
read_bytes, type, used_space, create_by, update_by, create_time, update_time
from ${tableName}
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="name != null and name != ''"> and name = #{name}</if>
<if test="type != null and type != ''"> and type = #{type}</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>
order by create_time desc
</select>
<select id="selectInitialDiskInfoById" parameterType="Long" resultMap="InitialDiskInfoResult">
<include refid="selectInitialDiskInfoVo"/>
where id = #{id}
@@ -56,11 +73,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="readTimes != null">read_times,</if>
<if test="writeBytes != null">write_bytes,</if>
<if test="readBytes != null">read_bytes,</if>
<!-- 新增的两个字段 -->
<if test="type != null and type != ''">type,</if>
<if test="usedSpace != null">used_space,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="clientId != null and clientId != ''">#{clientId},</if>
@@ -73,11 +93,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="readTimes != null">#{readTimes},</if>
<if test="writeBytes != null">#{writeBytes},</if>
<if test="readBytes != null">#{readBytes},</if>
<!-- 新增的两个字段 -->
<if test="type != null and type != ''">#{type},</if>
<if test="usedSpace != null">#{usedSpace},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</trim>
</insert>
<update id="updateInitialDiskInfo" parameterType="InitialDiskInfo">
@@ -93,6 +116,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="readTimes != null">read_times = #{readTimes},</if>
<if test="writeBytes != null">write_bytes = #{writeBytes},</if>
<if test="readBytes != null">read_bytes = #{readBytes},</if>
<!-- 新增的两个字段 -->
<if test="type != null and type != ''">type = #{type},</if>
<if test="usedSpace != null">used_space = #{usedSpace},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
@@ -106,14 +132,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteInitialDiskInfoByIds" parameterType="String">
delete from initial_disk_info where id in
delete from initial_disk_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsertInitialDiskInfo" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
INSERT IGNORE INTO initial_disk_info
<insert id="batchInsertInitialDiskInfo" parameterType="InitialDiskInfo">
INSERT IGNORE INTO ${tableName}
(
id,
client_id,
@@ -126,6 +152,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
read_times,
write_bytes,
read_bytes,
type,
used_space,
create_by,
update_by,
create_time,
@@ -145,6 +173,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.readTimes},
#{item.writeBytes},
#{item.readBytes},
#{item.type},
#{item.usedSpace},
#{item.createBy},
#{item.updateBy},
<choose>
@@ -166,14 +196,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)
</foreach>
</insert>
<select id="getDistDetailsMsgByClientId" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
<include refid="selectInitialDiskInfoVo"/>
select id, client_id, name, serial, total, write_speed, read_speed, write_times, read_times, write_bytes,
read_bytes, type, used_space, create_by, update_by, create_time, update_time
from ${tableName}
where client_id = #{clientId} and `name`= #{name}
order by create_time desc
limit 1
</select>
<select id="getAllDistName" parameterType="String" resultType="java.util.Map">
select name from initial_disk_info
select name from all_disk_name
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
</where>