| | |
| | | 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)); |
| | |
| | | |
| | | // 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(关联下属标注) |