furniture-3d-system-Wu/furniture-3d-system/docs/solutions/workflow-issues/product-hardware-route-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

1.4 KiB

title, date, module, problem_type, severity, symptoms, root_cause, resolution_type, status, confidence, tags, related_patterns
title date module problem_type severity symptoms root_cause resolution_type status confidence tags related_patterns
Product Hardware Route 分层收口到 Service/Repository 2026-02-15 product-hardware-route workflow_issue high
/api/product-hardware/[id] Route 直接操作 Prisma
Route 叠加参数解析、权限判断、数据访问与更新逻辑
历史实现未遵循 Route -> Service -> Repository 分层约束 code_fix active high
architecture
layering
route
service
repository
product-hardware
SEC-PRODHW-PERM-001

现象与影响

Route 层直接写 Prisma 会导致:

  • 权限逻辑散落,重复实现容易漂移。
  • 业务规则不可复用,后续接口扩展成本高。
  • 架构审查难以确认边界是否一致。

修复动作

  1. 新增 product-hardware.repository.ts 统一承接 ProductHardware 的查询/更新。
  2. 新增 product-hardware.service.ts 统一承接权限校验、业务校验与编排。
  3. src/app/api/product-hardware/[id]/route.ts 仅保留参数校验和统一响应,不再直连 Prisma。

验证

  • npm run type-check -- --pretty false 通过
  • npm test -- tests/lib/cad-panel-linking.test.ts --runInBand 通过

预防策略

  • Route 文件出现 prisma. 直接访问时,默认判定为架构违规。
  • 新接口先设计 Service 方法和 Repository 原子方法,再接入 Route。