feat(mapper): 添加物理删除功能并优化垃圾清理逻辑

- 在 GroupingMapper 和 MarkdownFileMapper 中添加物理删除方法
- 修改 TrashServiceImpl 中的 cleanTrash 方法,使用新增的物理删除方法
-优化了垃圾清理的 SQL 执行效率
This commit is contained in:
ikmkj
2025-08-01 22:50:50 +08:00
parent 15091c315e
commit 399c79b756
3 changed files with 6 additions and 2 deletions

View File

@@ -23,4 +23,6 @@ public interface GroupingMapper extends BaseMapper<Grouping> {
@Update("UPDATE grouping SET is_deleted = 0, deleted_at = NULL, deleted_by = NULL WHERE id = #{id}")
void restoreById(@Param("id") Long id);
@Delete("DELETE FROM grouping WHERE is_deleted = 1")
void physicalDeleteByIsDeleted();
}

View File

@@ -41,4 +41,6 @@ public interface MarkdownFileMapper extends BaseMapper<MarkdownFile> {
@Update("UPDATE markdown_file SET is_deleted = 0, deleted_at = NULL, deleted_by = NULL WHERE id = #{id}")
void restoreById(@Param("id") Long id);
@Delete("DELETE FROM markdown_file WHERE is_deleted = 1")
void physicalDeleteByIsDeleted();
}

View File

@@ -84,7 +84,7 @@ public class TrashServiceImpl implements TrashService {
@Override
@Transactional
public void cleanTrash() {
markdownFileMapper.delete(new QueryWrapper<MarkdownFile>().eq("is_deleted", 1));
groupingMapper.delete(new QueryWrapper<Grouping>().eq("is_deleted", 1));
markdownFileMapper.physicalDeleteByIsDeleted();
groupingMapper.physicalDeleteByIsDeleted();
}
}