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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
26 deletions
+34
-26
projects/app/src/pages/api/core/app/list.ts
+18
-14
projects/app/src/pages/api/core/dataset/list.ts
+16
-12
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
...
@@ -157,26 +157,30 @@ async function handler(req: ApiRequestProps<ListAppBody>): Promise<AppListItemTy
.
map
((
item
)
=>
item
.
permission
)
.
map
((
item
)
=>
item
.
permission
)
);
);
// Count app collaborators
return
new
AppPermission
({
const
clbCount
=
perList
.
filter
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
app
.
_id
)
).
length
;
return
{
Per
:
new
AppPermission
({
per
:
tmbPer
??
groupPer
??
AppDefaultPermissionVal
,
per
:
tmbPer
??
groupPer
??
AppDefaultPermissionVal
,
isOwner
:
String
(
app
.
tmbId
)
===
String
(
tmbId
)
||
teamPer
.
isOwner
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
// Inherit app, check parent folder clb
if
(
app
.
inheritPermission
&&
app
.
parentId
&&
!
AppFolderTypeList
.
includes
(
app
.
type
))
{
if
(
!
AppFolderTypeList
.
includes
(
app
.
type
)
&&
app
.
parentId
&&
app
.
inheritPermission
)
{
return
getPer
(
String
(
app
.
parentId
));
return
{
}
else
{
Per
:
getPer
(
String
(
app
.
parentId
)),
return
getPer
(
String
(
app
.
_id
));
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
{
return
{
...
...
projects/app/src/pages/api/core/dataset/list.ts
View file @
4b9b0dbb
...
@@ -127,29 +127,33 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
...
@@ -127,29 +127,33 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
datasetId
&&
!!
item
.
groupId
)
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
datasetId
&&
!!
item
.
groupId
)
.
map
((
item
)
=>
item
.
permission
)
.
map
((
item
)
=>
item
.
permission
)
);
);
return
new
DatasetPermission
({
const
clbCount
=
perList
.
filter
(
(
item
)
=>
String
(
item
.
resourceId
)
===
String
(
dataset
.
_id
)
).
length
;
return
{
Per
:
new
DatasetPermission
({
per
:
tmbPer
??
groupPer
??
DatasetDefaultPermissionVal
,
per
:
tmbPer
??
groupPer
??
DatasetDefaultPermissionVal
,
isOwner
:
String
(
dataset
.
tmbId
)
===
String
(
tmbId
)
||
teamPer
.
isOwner
isOwner
:
String
(
dataset
.
tmbId
)
===
String
(
tmbId
)
||
teamPer
.
isOwner
}),
});
privateDataset
:
dataset
.
type
===
'folder'
?
clbCount
<=
1
:
clbCount
===
0
};
};
const
getClbCount
=
(
datasetId
:
string
)
=>
{
return
perList
.
filter
((
item
)
=>
String
(
item
.
resourceId
)
===
String
(
datasetId
)).
length
;
};
};
// inherit
// inherit
if
(
if
(
dataset
.
inheritPermission
&&
dataset
.
inheritPermission
&&
dataset
.
parentId
&&
dataset
.
parentId
&&
dataset
.
type
!==
DatasetTypeEnum
.
folder
dataset
.
type
!==
DatasetTypeEnum
.
folder
)
{
)
{
return
getPer
(
String
(
dataset
.
parentId
));
return
{
}
else
{
Per
:
getPer
(
String
(
dataset
.
parentId
)),
return
getPer
(
String
(
dataset
.
_id
));
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
{
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