furniture-3d-system-Wu/furniture-3d-system/docs/solutions/workflow-issues/panel-route-service-permission-unification-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

37 lines
1.2 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: 产品板件路由权限收口到 Service
date: 2026-02-15
module: panel-route
problem_type: workflow_issue
severity: high
symptoms:
- Route 与 Service 同时维护产品权限判断
- Route 直连 Prisma,权限策略容易漂移
root_cause: 分层迁移不彻底,Controller 仍承担数据访问与业务判断
resolution_type: code_fix
status: active
confidence: high
tags: [architecture, route-service, panel]
related_patterns: [WF-HOLE-ROUTE-SERVICE-001]
---
## 现象与影响
`products/[id]/panels` 在 Route 层重复做查询和权限,Service 也有权限逻辑,导致规则双轨并行。
## 修复动作
1. `src/app/api/products/[id]/panels/route.ts` 移除 Prisma 和 `canView/canEdit` 分支。
2. `src/server/services/panel.service.ts` 的 `findByProductId` 接入权限校验(`ctx.user` 存在时执行 `canViewProduct`)。
3. Route 仅保留参数解析、调用 Service 与统一响应。
## 验证
- `npm run type-check -- --pretty false` 通过
- `npm test -- tests/api/auth-me.test.ts --runInBand` 通过
## 预防策略
- Route 层只做入口编排;权限与业务判断统一放在 Service 层,避免策略漂移。