feat: 新增冷热数据访问分离逻辑

This commit is contained in:
2025-07-01 10:34:39 +08:00
parent 414891c602
commit 1f47d7e9fe
15 changed files with 2459 additions and 26 deletions
@@ -29,4 +29,55 @@
<select id="findById" resultType="com.central.common.model.FileInfo">
SELECT * FROM file_info WHERE id = #{id}
</select>
<!-- 查询文件列表 -->
<select id="findList" resultType="com.central.common.model.FileInfo">
SELECT * FROM file_info
<where>
<if test="params.name != null and params.name != ''">
AND name LIKE CONCAT('%', #{params.name}, '%')
</if>
<if test="params.contentType != null and params.contentType != ''">
AND content_type LIKE CONCAT('%', #{params.contentType}, '%')
</if>
<if test="params.storageType != null and params.storageType != ''">
AND storage_type = #{params.storageType}
</if>
<if test="params.isImg != null">
AND is_img = #{params.isImg}
</if>
</where>
ORDER BY createTime DESC
</select>
<!-- 查询热数据文件列表 -->
<select id="selectHotDataFiles" resultType="com.central.common.model.FileInfo">
SELECT * FROM file_info
WHERE create_time >= #{hotDataThreshold}
AND size > 0
AND (storage_type IS NULL OR storage_type NOT LIKE '%S3%' OR storage_type NOT LIKE '%MINIO%')
AND (path IS NULL OR path NOT LIKE '%s3://%' OR path NOT LIKE '%minio%')
ORDER BY create_time DESC
LIMIT #{limit}
</select>
<!-- 根据存储类型查询文件 -->
<select id="selectFilesByStorageType" resultType="com.central.common.model.FileInfo">
SELECT * FROM file_info
WHERE storage_type = #{storageType}
AND size > 0
ORDER BY create_time DESC
LIMIT #{limit}
</select>
<!-- 查询需要同步的文件(不在S3中的OSS文件) -->
<select id="selectFilesNeedSync" resultType="com.central.common.model.FileInfo">
SELECT * FROM file_info
WHERE (storage_type IS NULL OR storage_type NOT LIKE '%S3%' OR storage_type NOT LIKE '%MINIO%')
AND (path IS NULL OR path NOT LIKE '%s3://%' OR path NOT LIKE '%minio%')
AND size > 0
ORDER BY create_time DESC
LIMIT #{limit}
</select>
</mapper>