chore: check off Task 2 (RbacModule + RbacService)

This commit is contained in:
2026-07-02 11:26:03 +08:00
parent 23e96dcfbd
commit cd62a6dbe2
2 changed files with 10 additions and 10 deletions

View File

@@ -260,7 +260,7 @@ git commit -m "feat(rbac): add Permission and Role entities, update User entity"
**依赖**: 先用 `forwardRef` 占位 AuthModule 引用Task 3 解决循环依赖。
- [ ] **Step 1: 创建 RbacModule**
- [x] **Step 1: 创建 RbacModule**
```typescript
// backend/src/rbac/rbac.module.ts
@@ -288,7 +288,7 @@ export class RbacModule implements OnModuleInit {
}
```
- [ ] **Step 2: 创建 RbacService — 种子数据方法**
- [x] **Step 2: 创建 RbacService — 种子数据方法**
`backend/src/rbac/rbac.service.ts` 中,先定义权限点常量和预设角色,然后实现 `seedData()`
@@ -451,7 +451,7 @@ export class RbacService {
}
```
- [ ] **Step 3: 实现角色 CRUD 方法**
- [x] **Step 3: 实现角色 CRUD 方法**
在同一个 `RbacService` 中追加:
@@ -495,7 +495,7 @@ export class RbacService {
}
```
- [ ] **Step 4: 实现权限查询方法**
- [x] **Step 4: 实现权限查询方法**
```typescript
async findAllPermissions(): Promise<Permission[]> {
@@ -529,7 +529,7 @@ export class RbacService {
}
```
- [ ] **Step 5: 编译验证**
- [x] **Step 5: 编译验证**
```bash
cd backend && npx tsc --noEmit
@@ -537,7 +537,7 @@ cd backend && npx tsc --noEmit
预期:无类型错误。
- [ ] **Step 6: Commit**
- [x] **Step 6: Commit**
```bash
git add backend/src/rbac/

View File

@@ -9,10 +9,10 @@
## 2. RBAC 服务层
- [ ] 2.1 创建 RbacModule 和 RbacService提供 findAllRoles/findRoleById/createRole/updateRole/deleteRole 方法
- [ ] 2.2 实现角色 CRUD含权限关联创建角色时同时写入 RolePermission更新时删除旧关联重建
- [ ] 2.3 实现 getUserPermissions 方法:通过 User→UserRole→Role→RolePermission→Permission 链查询,去重后返回权限 code 列表
- [ ] 2.4 实现 getPermissionTree 方法:返回按 group 分组的权限树,供前端权限一览和管理页使用
- [x] 2.1 创建 RbacModule 和 RbacService提供 findAllRoles/findRoleById/createRole/updateRole/deleteRole 方法
- [x] 2.2 实现角色 CRUD含权限关联创建角色时同时写入 RolePermission更新时删除旧关联重建
- [x] 2.3 实现 getUserPermissions 方法:通过 User→UserRole→Role→RolePermission→Permission 链查询,去重后返回权限 code 列表
- [x] 2.4 实现 getPermissionTree 方法:返回按 group 分组的权限树,供前端权限一览和管理页使用
- [ ] 2.5 创建 RbacController角色 CRUD + 权限树 + 用户-角色分配接口,所有接口加 @RequirePermission 守卫
## 3. 权限守卫实现