🟡 P1 | PATCH /knowledge-items/{id} 支持 parentId 和重命名 #65

Closed
opened 2026-05-30 16:25:32 +08:00 by wangdl · 2 comments
Owner

背景

iOS 知识点长按菜单有「重命名」和「移动到」两个操作。UpdateKnowledgeItemRequest 当前仅支持 title/content/summary,但 PATCH 接口可能需要确认 parentId 支持。

需求

UpdateKnowledgeItemRequest 新增字段:
parentId: String? // 移动到目标文件夹(null = 根目录)
确认 title 字段在 PATCH 时正常更新。

关联

重命名:现有 PATCH 接口已支持 title 更新,需前端接入
移动到:需新增 parentId 支持

## 背景 iOS 知识点长按菜单有「重命名」和「移动到」两个操作。UpdateKnowledgeItemRequest 当前仅支持 title/content/summary,但 PATCH 接口可能需要确认 parentId 支持。 ## 需求 UpdateKnowledgeItemRequest 新增字段: parentId: String? // 移动到目标文件夹(null = 根目录) 确认 title 字段在 PATCH 时正常更新。 ## 关联 重命名:现有 PATCH 接口已支持 title 更新,需前端接入 移动到:需新增 parentId 支持
wangdl added this to the H0:iOS 对接阻断修复(P0) milestone 2026-05-30 16:25:32 +08:00
Author
Owner

修复汇报 (2026-06-05)

实现

  • Service.update() — 新增 parentId 校验:如果传入非 null 值,检查目标父节点存在且属于同一知识库,否则抛 BadRequestException
  • parentId: null 表示移动到根目录
  • title 更新已通过 Record<string, any> 透传支持

状态

完成。

## 修复汇报 (2026-06-05) ### 实现 - **Service.update()** — 新增 `parentId` 校验:如果传入非 null 值,检查目标父节点存在且属于同一知识库,否则抛 `BadRequestException` - `parentId: null` 表示移动到根目录 - `title` 更新已通过 `Record<string, any>` 透传支持 ### 状态 ✅ 完成。
Author
Owner

Bug 修复 (2026-06-06)

问题

KnowledgeItemsRepository.update() 使用 Record<string, any> 直接透传给 Prisma,存在 Mass Assignment 漏洞。攻击者可传入 userIddeletedAtstatus 等任意字段覆写数据库记录。

修复

新增字段白名单:titlecontentsummaryparentIditemTypesourceTypeorderIndexstatusdurationSeconds。仅白名单内的字段可被更新。

状态

已修复。

## Bug 修复 (2026-06-06) ### 问题 `KnowledgeItemsRepository.update()` 使用 `Record<string, any>` 直接透传给 Prisma,存在 Mass Assignment 漏洞。攻击者可传入 `userId`、`deletedAt`、`status` 等任意字段覆写数据库记录。 ### 修复 新增字段白名单:`title`、`content`、`summary`、`parentId`、`itemType`、`sourceType`、`orderIndex`、`status`、`durationSeconds`。仅白名单内的字段可被更新。 ### 状态 ✅ 已修复。
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/api-server#65
No description provided.