Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
4b9b0dbb
authored
Dec 11, 2024
by
Archer
Committed by
GitHub
Dec 11, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: private app check (#3376)
* perf: private app check * perf: clb count
parent
c0135f5f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
31 deletions
+39
-31
projects/app/src/pages/api/core/app/list.ts
+20
-16
projects/app/src/pages/api/core/dataset/list.ts
+19
-15
No files found.
projects/app/src/pages/api/core/app/list.ts
View file @
4b9b0dbb
...
...
@@ -157,26 +157,30 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
.
map
((
item
)
=>
item
.
permission
)
);
// Count app collaborators
const
clbCount
=
perList
.
filter
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
app
.
_id
)
).
length
;
return
new
AppPermission
({
per
:
tmbPer
??
groupPer
??
AppDefaultPermissionVal
,
isOwner
:
String
(
app
.
tmbId
)
===
String
(
tmbId
)
||
teamPer
.
isOwner
});
};
return
{
Per
:
new
AppPermission
({
per
:
tmbPer
??
groupPer
??
AppDefaultPermissionVal
,
isOwner
:
String
(
app
.
tmbId
)
===
String
(
tmbId
)
||
teamPer
.
isOwner
}),
privateApp
:
AppFolderTypeList
.
includes
(
app
.
type
)
?
clbCount
<=
1
:
clbCount
===
0
};
const
getClbCount
=
(
appId
:
string
)
=>
{
return
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
String
(
appId
)).
length
;
};
// Inherit app
if
(
app
.
inheritPermission
&&
app
.
parentId
&&
!
AppFolderTypeList
.
includes
(
app
.
type
))
{
return
getPer
(
String
(
app
.
parentId
));
}
else
{
return
getPer
(
String
(
app
.
_id
));
// Inherit app, check parent folder clb
if
(
!
AppFolderTypeList
.
includes
(
app
.
type
)
&&
app
.
parentId
&&
app
.
inheritPermission
)
{
return
{
Per
:
getPer
(
String
(
app
.
parentId
)),
privateApp
:
getClbCount
(
String
(
app
.
parentId
))
<=
1
};
}
return
{
Per
:
getPer
(
String
(
app
.
_id
)),
privateApp
:
AppFolderTypeList
.
includes
(
app
.
type
)
?
getClbCount
(
String
(
app
.
_id
))
<=
1
:
getClbCount
(
String
(
app
.
_id
))
===
0
};
})();
return
{
...
...
projects/app/src/pages/api/core/dataset/list.ts
View file @
4b9b0dbb
...
...
@@ -127,29 +127,33 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
datasetId
&&
!!
item
.
groupId
)
.
map
((
item
)
=>
item
.
permission
)
);
const
clbCount
=
perList
.
filter
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
dataset
.
_id
)
).
length
;
return
{
Per
:
new
DatasetPermission
({
per
:
tmbPer
??
groupPer
??
DatasetDefaultPermissionVal
,
isOwner
:
String
(
dataset
.
tmbId
)
===
String
(
tmbId
)
||
teamPer
.
isOwner
}),
privateDataset
:
dataset
.
type
===
'folder'
?
clbCount
<=
1
:
clbCount
===
0
};
return
new
DatasetPermission
({
per
:
tmbPer
??
groupPer
??
DatasetDefaultPermissionVal
,
isOwner
:
String
(
dataset
.
tmbId
)
===
String
(
tmbId
)
||
teamPer
.
isOwner
});
};
const
getClbCount
=
(
datasetId
:
string
)
=>
{
return
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
String
(
datasetId
)).
length
;
};
// inherit
if
(
dataset
.
inheritPermission
&&
dataset
.
parentId
&&
dataset
.
type
!==
DatasetTypeEnum
.
folder
)
{
return
getPer
(
String
(
dataset
.
parentId
));
}
else
{
return
getPer
(
String
(
dataset
.
_id
));
return
{
Per
:
getPer
(
String
(
dataset
.
parentId
)),
privateDataset
:
getClbCount
(
String
(
dataset
.
parentId
))
<=
1
};
}
return
{
Per
:
getPer
(
String
(
dataset
.
_id
)),
privateDataset
:
dataset
.
type
===
DatasetTypeEnum
.
folder
?
getClbCount
(
String
(
dataset
.
_id
))
<=
1
:
getClbCount
(
String
(
dataset
.
_id
))
===
0
};
})();
return
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment