Files
leaudit-platform-frontend/app
TanWenyan 7f1a05107f feat(evaluation): 模块1.4 - 新增评查点分组批量操作接口
## 主要改进

### 1. 新增 batchUpdateRuleGroupStatus 函数(批量启用/禁用)
-  参数验证(ID列表不为空,每个ID有效)
-  逐个验证分组存在性
-  逐个执行更新操作
-  返回详细的操作结果
  - updated_count: 成功更新的数量
  - failed_ids: 失败的ID列表
  - errors: 详细的错误信息(包含ID和错误原因)

### 2. 新增 batchDeleteRuleGroups 函数(批量删除)
-  参数验证(ID列表不为空,每个ID有效)
-  采用安全的阻止删除策略
-  逐个检查并删除分组
-  返回详细的操作结果和错误信息
  - deleted_count: 成功删除的数量
  - failed_ids: 失败的ID列表
  - errors: 详细的错误信息(包含子分组/评查点检查结果)

### 3. 批量操作特性
-  **逐个处理**:确保每个分组都能被正确处理
-  **部分成功支持**:即使部分分组操作失败,成功的也会被处理
-  **详细的错误追踪**:记录每个失败的ID及其失败原因
-  **安全性优先**:批量删除继承单个删除的安全检查

### 4. 返回值结构

```typescript
// 批量更新状态
{
  success: boolean;          // 是否全部成功
  updated_count: number;     // 成功更新的数量
  failed_ids: string[];      // 失败的ID列表
  errors?: Array<{           // 详细错误(可选)
    id: string;
    error: string;
  }>;
}

// 批量删除
{
  success: boolean;          // 是否全部成功
  deleted_count: number;     // 成功删除的数量
  failed_ids: string[];      // 失败的ID列表
  errors?: Array<{           // 详细错误(可选)
    id: string;
    error: string;
    details?: {              // 删除失败详情
      hasChildren?: boolean;
      hasPoints?: boolean;
    };
  }>;
}
```

## 使用示例

### 批量启用分组
```typescript
const result = await batchUpdateRuleGroupStatus(
  ['1', '2', '3'],
  true,
  token
);

if (result.success) {
  console.log(`成功启用 ${result.updated_count} 个分组`);
} else {
  console.log(`成功 ${result.updated_count} 个,失败 ${result.failed_ids.length} 个`);
  result.errors?.forEach(err => {
    console.log(`分组 ${err.id}: ${err.error}`);
  });
}
```

### 批量删除分组
```typescript
const result = await batchDeleteRuleGroups(['1', '2'], token);

if (result.success) {
  console.log(`成功删除 ${result.deleted_count} 个分组`);
} else {
  result.errors?.forEach(err => {
    if (err.details?.hasChildren) {
      console.log(`分组 ${err.id} 有子分组,无法删除`);
    }
    if (err.details?.hasPoints) {
      console.log(`分组 ${err.id} 有评查点,无法删除`);
    }
  });
}
```

## 相关文件
- app/api/evaluation_points/rule-groups.ts

## 验收清单
- [x] TypeScript 类型检查通过
- [x] 完整的参数验证
- [x] 支持部分成功场景
- [x] 详细的错误追踪
- [x] 安全的删除策略

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 12:16:46 +08:00
..
2025-11-24 18:41:14 +08:00
2025-11-22 16:03:56 +08:00
2025-11-24 20:52:00 +08:00
2025-06-04 11:25:53 +08:00
2025-11-24 18:41:14 +08:00