You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
1.4 KiB

# 02 — 全量资源树查询 + 新增/编辑节点(含层级约束)
**What to build:** 管理员可通过 `GET /api/resources` 获取全量资源扁平数组(前端自行按 parentId 组树)。`POST /api/resources` 以 `ResourceNode` JSON body 新增或编辑节点(含 id=覆盖,无 id=新增)。服务端执行层级约束校验、字段必填校验、编辑时 type 不可变。Config 放行 `/api/resources/**`
**Blocked by:** 01(需要 SysMenu 新字段 + MenuType 枚举 + ResourceNode DTO)。
**Status:** ready-for-agent
- [ ] `GET /api/resources` 返回全量 `ResourceNode[]` 扁平数组,含全部类型节点(catalog/menu/button),不按角色过滤
- [ ] `POST /api/resources` 接受 `ResourceNode` JSON body,无 id 新增、有 id 覆盖编辑
- [ ] 层级约束校验:根只允许 catalog/menu;catalog 只允许 menu;menu 只允许 button;button 不可挂子节点——6 种非法组合返回明确错误信息
- [ ] 字段必填校验:menu 缺 route 拒绝;button 缺 perms(非空)/ denyBehavior / apiUrl / status 拒绝
- [ ] 编辑时 type 不可变:传入 id 已存在但 type 与现有不一致时拒绝
- [ ] SecurityConfig 放行 `/api/resources/**`(非认证请求可访问管理端)
- [ ] TDD 测试覆盖:6 种层级组合正反例、menu 缺 route 拒绝、button 缺必填字段拒绝、编辑锁 type