liuyun d086df2ba3 chore(openspec): add init-shared-foundation change
shared 三层 spec:platform / data-model / api-contract + design + tasks

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-10 15:23:53 +08:00

1.9 KiB
Raw Blame History

1. 后端工程地基

  • 1.1 在 sysmgr-nest 接入 Prisma + MySQL,配置 PrismaService 与连接
  • 1.2 配置全局响应封装拦截器({code, message, data})
  • 1.3 配置全局异常过滤器(错误码分段 400xx/401xx/403xx/404xx/409xx/500xx)

2. 数据模型落地

  • 2.1 编写 Prisma schema:tenant / user / role / resource / org / dict_type / dict_item / config
  • 2.2 编写 Prisma schema:audit_log / login_log / refresh_token / user_role / role_resource / role_org
  • 2.3 生成并执行首版 migration
  • 2.4 定义 TS 应用层枚举(status / resource type / data_scope 等)

3. 认证与鉴权

  • 3.1 实现密码哈希工具(argon2/bcrypt)
  • 3.2 实现登录接口(tenantCode + username + password → access + refresh)
  • 3.3 实现刷新接口(refresh 旋转,作废旧 token)
  • 3.4 实现登出 / 踢人(置 revoked_at)
  • 3.5 实现 JWT access 签发与校验守卫
  • 3.6 实现 @RequirePermissions 装饰器与权限守卫(三级鉴权)

4. 横切过滤器

  • 4.1 实现多租户 tenant_id 过滤(Prisma 扩展 client 统一注入)
  • 4.2 实现软删 deleted_at 过滤
  • 4.3 实现数据权限 data_scope 可见部门计算与 org_id 过滤

5. 核心域 CRUD

  • 5.1 租户管理 CRUD
  • 5.2 用户管理 CRUD(含密码重置、启停/锁定)
  • 5.3 角色管理 CRUD(含资源分配、data_scope)
  • 5.4 资源管理 CRUD(树形,menu/button/api)
  • 5.5 组织管理 CRUD(树形)
  • 5.6 字典管理 CRUD(类型 + 项)
  • 5.7 参数配置 CRUD
  • 5.8 操作日志 / 登录日志查询接口

6. 前端地基

  • 6.1 封装 API client({code,message,data} 统一处理、token 注入、401 自动刷新)
  • 6.2 登录页 + 路由守卫(未登录跳转)
  • 6.3 对接认证接口(login / refresh / logout)