feat(trash): 优化回收站物品恢复和永久删除逻辑

- 在 GroupingMapper 和 MarkdownFileMapper 中添加物理删除和恢复的 SQL 操作
- 优化 HomePage组件中的删除操作,删除后刷新分组树并回到主视图
- 在 TrashServiceImpl 中实现物品恢复和永久删除的业务逻辑- 为 TrashItemVo 中的 deletedAt 字段添加 JSON 格式化注解
This commit is contained in:
ikmkj
2025-08-01 00:14:34 +08:00
parent c448ababa9
commit b0a714df83
6 changed files with 38 additions and 28 deletions

View File

@@ -1,6 +1,7 @@
package com.test.bijihoudaun.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.test.bijihoudaun.entity.Grouping;
import com.test.bijihoudaun.entity.MarkdownFile;
import com.test.bijihoudaun.entity.TrashItemVo;
@@ -62,19 +63,9 @@ public class TrashServiceImpl implements TrashService {
@Transactional
public void restoreItem(String id, String type) {
if ("note".equals(type)) {
MarkdownFile file = new MarkdownFile();
file.setId(Long.parseLong(id));
file.setIsDeleted(0);
file.setDeletedAt(null);
file.setDeletedBy(null);
markdownFileMapper.updateById(file);
markdownFileMapper.restoreById(Long.parseLong(id));
} else if ("group".equals(type)) {
Grouping group = new Grouping();
group.setId(Long.parseLong(id));
group.setIsDeleted(0);
group.setDeletedAt(null);
group.setDeletedBy(null);
groupingMapper.updateById(group);
groupingMapper.restoreById(Long.parseLong(id));
}
}
@@ -82,11 +73,11 @@ public class TrashServiceImpl implements TrashService {
@Transactional
public void permanentlyDeleteItem(String id, String type) {
if ("note".equals(type)) {
markdownFileMapper.deleteById(Long.parseLong(id));
markdownFileMapper.physicalDeleteById(Long.parseLong(id));
} else if ("group".equals(type)) {
// 删除分组时,也删除其下的所有笔记
groupingMapper.deleteById(Long.parseLong(id));
markdownFileMapper.delete(new QueryWrapper<MarkdownFile>().eq("grouping_id", id));
// 永久删除分组时,也永久删除其下的所有笔记
groupingMapper.physicalDeleteById(Long.parseLong(id));
markdownFileMapper.physicalDeleteByGroupingId(Long.parseLong(id));
}
}