-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathresource-authorization.ts
More file actions
105 lines (98 loc) · 2.36 KB
/
resource-authorization.ts
File metadata and controls
105 lines (98 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import { Result } from '@/request/Result'
import { get, put, post, del } from '@/request/index'
import type { Ref } from 'vue'
import type { pageRequest } from '@/api/type/common'
const prefix = '/workspace'
/**
* 系统资源授权获取资源权限
* @query 参数
*/
const getResourceAuthorization: (
workspace_id: string,
user_id: string,
resource: string,
params?: any,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (workspace_id, user_id, resource, params, loading) => {
return get(
`${prefix}/${workspace_id}/user_resource_permission/user/${user_id}/resource/${resource}`,
params,
loading,
)
}
/**
* 系统资源授权修改成员权限
* @param 参数 member_id
* @param 参数 {
[
{
"target_id": "string",
"permission": "NOT_AUTH"
}
]
}
*/
const putResourceAuthorization: (
workspace_id: string,
user_id: string,
resource: string,
body: any,
loading?: Ref<boolean>,
) => Promise<Result<any>> = (workspace_id, user_id, resource, body, loading) => {
return put(
`${prefix}/${workspace_id}/user_resource_permission/user/${user_id}/resource/${resource}`,
body,
{},
loading,
)
}
/**
* 获取成员列表
* @query 参数
*/
const getUserList: (workspace_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
workspace_id,
loading,
) => {
return get(`${prefix}/${workspace_id}/user_list`, undefined, loading)
}
const getUserMember: (workspace_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
workspace_id,
loading,
) => {
return get(`${prefix}/${workspace_id}/user_member`, undefined, loading)
}
/**
* 获得系统文件夹列表
* @params 参数
* source : APPLICATION, KNOWLEDGE, TOOL
* data : {name: string}
*/
const getSystemFolder: (
workspace_id: string,
source: string,
data?: any,
loading?: Ref<boolean>,
) => Promise<Result<Array<any>>> = (workspace_id, source, data, loading) => {
if (source == 'MODEL') {
return Promise.resolve(
Result.success([
{
id: 'default',
name: '根目录',
desc: null,
parent_id: null,
children: [],
},
]),
)
}
return get(`${prefix}/${workspace_id}/${source}/folder`, data, loading)
}
export default {
getResourceAuthorization,
putResourceAuthorization,
getUserList,
getUserMember,
getSystemFolder,
}