export function hasPermission(user: User, permissionName: string): boolean {
for (const role of user.roles) {
for (const permission of role.permissions) {
if (permission.name === permissionName) {
return true;
}
}
}
return false;
}
```
##### **index.ts**
```
// RBAC模块的入口文件
export * from "./User";
export * from "./Role";
export * from "./Permission";
export * from "./RBAC";
```