2022-10-06 10:29:53 +08:00
|
|
|
|
# ACLResource
|
|
|
|
|
|
|
|
|
|
ACLResource,ACL 系统中的资源类。在 ACL 系统中,为用户授予权限时会自动创建对应的资源。
|
|
|
|
|
|
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
## 类方法
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
### `constructor()`
|
|
|
|
|
构造函数
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
**签名**
|
|
|
|
|
* `constructor(options: AclResourceOptions)`
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
**类型**
|
2022-10-06 10:29:53 +08:00
|
|
|
|
```typescript
|
|
|
|
|
type ResourceActions = { [key: string]: RoleActionParams };
|
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
interface AclResourceOptions {
|
|
|
|
|
name: string; // 资源名称
|
|
|
|
|
role: ACLRole; // 资源所属角色
|
|
|
|
|
actions?: ResourceActions;
|
|
|
|
|
}
|
|
|
|
|
```
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
**详细信息**
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
`RoleActionParams`详见 [`aclRole.grantAction`](./acl-role.md#grantaction)
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
|
|
|
|
### `getActions()`
|
|
|
|
|
|
|
|
|
|
获取资源的所有 Action,返回结果为 `ResourceActions` 对象。
|
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
### `getAction()`
|
2022-10-06 10:29:53 +08:00
|
|
|
|
根据名称返回 Action 的参数配置,返回结果为 `RoleActionParams` 对象。
|
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
**详细信息**
|
|
|
|
|
|
|
|
|
|
`RoleActionParams`详见 [`aclRole.grantAction`](./acl-role.md#grantaction)
|
|
|
|
|
|
|
|
|
|
### `setAction()`
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
|
|
|
|
在资源内部设置一个 Action 的参数配置,返回结果为 `RoleActionParams` 对象。
|
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
**签名**
|
|
|
|
|
* `setAction(name: string, params: RoleActionParams)`
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
**详细信息**
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
* name - 要设置的 action 名称
|
|
|
|
|
* `RoleActionParams`详见 [`aclRole.grantAction`](./acl-role.md#grantaction)
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
### `setActions()`
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
**签名**
|
|
|
|
|
* `setActions(actions: ResourceActions)`
|
2022-10-06 10:29:53 +08:00
|
|
|
|
|
2022-10-16 19:16:14 +08:00
|
|
|
|
批量调用 `setAction` 的便捷方法
|