furniture-3d-system-Wu/furniture-3d-system/docs/solutions/workflow-issues/hole-route-service-layering-20260215.md
WuYongJie 5821d73291 初始提交:3D家具安装展示系统
包含:
- furniture-3d-system:Next.js 16 全栈应用(资产中心、产品管理、3D装配动画)
- autocad-plugin:AutoCAD 家具导出插件源码
- 资产中心改造:编辑弹窗化、删除功能、Toast反馈、自定义Select组件

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 14:00:19 +08:00

40 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Hole Route 去 Repository 直连并收口到 Service
date: 2026-02-15
module: holes-route
problem_type: workflow_issue
severity: high
symptoms:
- /api/holes Route 直接调用 holeRepository/panelRepository 承担筛选、数量校验、删除编排
- Route 过重,分层边界不清晰,权限与删除策略散落在接口层
root_cause: 历史实现为了快速交付在 Route 层叠加了数据访问与业务编排
resolution_type: code_fix
status: active
confidence: high
tags: [architecture, route-layer, service-layer, holes]
related_patterns: [SEC-HOLE-PERM-001]
---
## 现象与影响
`/api/holes` 同时承担参数解析、数据访问、业务编排,导致:
- 违反 `Route -> Service -> Repository` 分层约束。
- 相同规则(筛选、删除限额、权限)难以复用,后续接口容易漂移。
## 修复动作
1. `src/app/api/holes/route.ts` 移除 `holeRepository/panelRepository` 直连。
2. 新增 `holeService.listByFilter` 与 `holeService.deleteByFilter`,将筛选、权限、数量校验与删除编排统一下沉到 Service。
3. Route 仅保留参数解析、输入校验与统一响应封装。
## 验证
- `npm run type-check -- --pretty false` 通过
- `npm test -- tests/lib/cad-panel-linking.test.ts --runInBand` 通过
## 预防策略
- 新增 API 时先定义 Service 方法,再编写 Route;Route 不允许直接引入 Repository。
- Code Review 对 Route 层增加规则:若出现 `*Repository` 依赖需给出例外说明,否则驳回。