Files
YG_FT/frontend/src/api/modules/resource-acl.ts
2026-08-17 09:15:36 +08:00

24 lines
679 B
TypeScript
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.
import { get, put } from '../request'
/** ACL 条目 */
export interface AclEntry {
principal_type: 'user' | 'role'
principal_id: string
permissions: string[]
}
/** 资源 ACL含已有条目 */
export interface ResourceAcl {
resource_type: string
resource_id: string
entries: AclEntry[]
}
/** 查询资源 ACL */
export const getResourceAcl = (resourceType: string, resourceId: string) =>
get<ResourceAcl>(`/resources/${resourceType}/${resourceId}/acl`)
/** 设置资源 ACL */
export const setResourceAcl = (resourceType: string, resourceId: string, entries: AclEntry[]) =>
put<ResourceAcl>(`/resources/${resourceType}/${resourceId}/acl`, { entries })