Documentation
¶
Index ¶
- func AllowIfAdmin() privacy.QueryMutationRule
- func DenyFieldsMutationRule(ctx context.Context, m ent.Mutation, fields ...string) error
- func DenyIfNoViewer() privacy.QueryMutationRule
- func GetClientFromMutation(m ent.Mutation) (any, bool)
- func LimitFieldAccessRule(ctx context.Context, m ent.Mutation, field string, requiredPermission string) error
- func OwnerOnlyRule(ctx context.Context, f Filter) error
- func PermissionRule(ctx context.Context, f Filter) error
- func SoftDeleteRule(ctx context.Context, f Filter) error
- func TenantFilterRule(ctx context.Context, f Filter) error
- type Filter
- type TenantPrivacy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowIfAdmin ¶
func AllowIfAdmin() privacy.QueryMutationRule
AllowIfAdmin is a rule that returns Allow decision if the viewer is admin.
func DenyFieldsMutationRule ¶
DenyFieldsMutationRule 禁止修改特定字段的 Mutation 规则 参数说明: ctx: 上下文 m: 传入的对象,在 Mutation 阶段它是具体的 Mutation 实例 fields: 需要保护(禁止修改)的字段名
func DenyIfNoViewer ¶
func DenyIfNoViewer() privacy.QueryMutationRule
DenyIfNoViewer is a rule that denies the operation if there is no viewer in the context.
func GetClientFromMutation ¶
GetClientFromMutation 通过反射从 m 上调用 Client 方法。 返回 (client, true) 表示成功获取;否则返回 (nil, false)。
func LimitFieldAccessRule ¶
func LimitFieldAccessRule(ctx context.Context, m ent.Mutation, field string, requiredPermission string) error
LimitFieldAccessRule 限制特定字段的访问修改权限 参数说明: ctx: 上下文 m: 传入的对象,在 Mutation 阶段它是具体的 Mutation 实例 field: 需要保护的字段名 requiredPermission: 修改该字段所需的权限标识
func PermissionRule ¶
PermissionRule 是一个通用的数据权限过滤规则,用于在查询时注入基于数据权限范围的过滤条件。 该规则会根据当前 ViewerContext 中的数据权限信息,动态添加过滤谓词,确保数据访问符合权限要求。 适用于包含 org_unit_id 和 created_by 字段的实体查询。
func SoftDeleteRule ¶
SoftDeleteRule 注入软删除过滤规则,隐藏已软删除的数据记录
Types ¶
type Filter ¶
Filter is the interface that wraps the Where function for filtering nodes in queries and mutations.