nocobase/docs/zh-CN/api/acl/acl-resource.md
ChengLei Shao 4d6363b47a
Doc/db repository (#896)
* docs: update database repository docs

* docs: single relation repository docs

* docs: has many relation repository docs

* docs: belongs to many  relation repository docs

* docs: acl

* docs: actions

Co-authored-by: chenos <chenlinxh@gmail.com>
2022-10-16 19:16:14 +08:00

58 lines
1.3 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.

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