Files
leaudit-platform-frontend/app/api
TanWenyan a0611a3a13 fix(evaluation): 修复 PostgREST endpoint 格式错误导致 404
## 问题描述
更新或获取评查点时出现 404 错误:
- GET http://172.16.0.55:8073/evaluation_points/736 (404 Not Found)
- 用户报告"删除失败"

## 根本原因
`getRule` 和 `updateRule` 函数使用了错误的 PostgREST endpoint 格式:
-  错误:`evaluation_points/${id}` (REST风格路径)
-  正确:`evaluation_points?id=eq.${id}` (PostgREST查询参数)

PostgREST **不支持** `/resource/{id}` 风格的路径参数,
必须使用查询参数格式:`/resource?id=eq.{id}`

## 修复内容

### getRule 函数 (line 416-470)
- 更新endpoint从 `evaluation_points/${id}` 为 `'evaluation_points'`
- 添加 `filter: { 'id': \`eq.${id}\` }` 到 PostgrestParams
- 更新响应数据处理逻辑,支持数组和包装对象两种格式
- 改进错误处理,返回404而不是500

### updateRule 函数 (line 728-754)
- 更新endpoint从 `evaluation_points/${id}` 为 `'evaluation_points'`
- 添加filter参数:`{ id: parseInt(id) }` 到 `postgrestPut` 第三个参数
- 更新响应数据处理逻辑,支持数组和包装对象两种格式
- 修复数据映射,使用 `updatedRule` 而不是 `response.data.data`

## 技术说明
PostgREST 标准查询语法:
- 单条记录查询:`GET /table?id=eq.123`
- 更新操作:`PATCH /table?id=eq.123` + body
- 不支持:`GET /table/123` 或 `PATCH /table/123`

## 测试建议
1. 刷新浏览器页面(Ctrl+F5)
2. 尝试编辑评查点并保存
3. 检查控制台不再出现404错误
4. 验证更新成功并正确返回数据
2025-11-25 16:38:07 +08:00
..
2025-11-24 18:41:14 +08:00