From a95db5fc78b3f86df131cc7271f06a053a9b2611 Mon Sep 17 00:00:00 2001
From: zhaowenyu <35589726@qq.com>
Date: Mon, 09 Mar 2026 14:42:25 +0800
Subject: [PATCH] 2026-03-09 优化

---
 ard-sample/src/main/java/com/ard/sample/annotation/service/impl/AnnotationDirectoryServiceImpl.java |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/ard-sample/src/main/java/com/ard/sample/annotation/service/impl/AnnotationDirectoryServiceImpl.java b/ard-sample/src/main/java/com/ard/sample/annotation/service/impl/AnnotationDirectoryServiceImpl.java
index 6ba5f04..577addc 100644
--- a/ard-sample/src/main/java/com/ard/sample/annotation/service/impl/AnnotationDirectoryServiceImpl.java
+++ b/ard-sample/src/main/java/com/ard/sample/annotation/service/impl/AnnotationDirectoryServiceImpl.java
@@ -45,12 +45,32 @@
         return updateById(entity);
     }
 
+    /**
+     * 新增:修改目录显示状态
+     */
+    @Override
+    public boolean updateDirectoryVisible(String id, Boolean isTrue) {
+        if (id == null || id.isEmpty() || isTrue == null) {
+            log.error("修改目录显示状态失败:参数非法,id={}, isTrue={}", id, isTrue);
+            return false;
+        }
+        AnnotationDirectoryEntity entity = new AnnotationDirectoryEntity();
+        entity.setId(id);
+        entity.setIsTrue(isTrue);
+        return updateById(entity);
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class) // 事务保证级联删除
-    public boolean deleteDirectory(Integer id) {
-        if (id == null) {
+    public boolean deleteDirectory(String id) {
+        if (id == null || id.isEmpty()) {
             log.error("删除目录失败:ID为空");
             return false;
+        }
+        // ====================== 关键:不允许删除默认文件夹 ======================
+        if ("default_directory_00000001".equals(id)) {
+            log.error("删除目录失败:默认文件夹不允许删除");
+            throw new RuntimeException("默认文件夹不允许删除");
         }
         // 1. 删除目录下所有标记
         annotationMapper.deleteByMap(Map.of("directory_id", id));
@@ -74,7 +94,7 @@
 
         // 2. 批量查询所有标注,按目录ID分组(减少数据库查询次数)
         List<AnnotationEntity> allAnnotations = annotationService.list();
-        Map<Integer, List<AnnotationEntity>> annotationMap = allAnnotations.stream()
+        Map<String, List<AnnotationEntity>> annotationMap = allAnnotations.stream()
                 .collect(Collectors.groupingBy(AnnotationEntity::getDirectoryId));
 
         // 3. 遍历目录,组装DTO(关联下属标注)

--
Gitblit v1.9.3