Skip to content

Commit 4eda4a0

Browse files
committed
feat: add scope parameter to ToolTreeSerializer and update get_tools method
1 parent ee96760 commit 4eda4a0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

apps/tools/serializers/tool.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ def add(self, instance, with_valid=True):
538538

539539
class ToolTreeSerializer(serializers.Serializer):
540540
workspace_id = serializers.CharField(required=True, label=_('workspace id'))
541+
scope = serializers.CharField(required=True, label=_('scope'))
541542

542543
def get_tools(self, folder_id):
543544
self.is_valid(raise_exception=True)
@@ -553,8 +554,11 @@ def get_tools(self, folder_id):
553554
folders_data = ToolFolderFlatSerializer(child_folders, many=True).data
554555

555556
# 获取当前文件夹下的工具
556-
tools = QuerySet(Tool).filter(Q(workspace_id=self.data.get('workspace_id')) &
557-
Q(folder_id=folder_id))
557+
tools = QuerySet(Tool).filter(
558+
Q(workspace_id=self.data.get('workspace_id')) &
559+
Q(scope=self.data.get('scope')) &
560+
Q(folder_id=folder_id)
561+
)
558562
tools_data = ToolModelSerializer(tools, many=True).data
559563

560564
# 返回包含文件夹和工具的结构

apps/tools/views/tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def post(self, request: Request, workspace_id: str):
6868
)
6969
def get(self, request: Request, workspace_id: str):
7070
return result.success(ToolTreeSerializer(
71-
data={'workspace_id': workspace_id}
71+
data={'workspace_id': workspace_id, 'scope': ToolScope.WORKSPACE, 'user_id': request.user.id}
7272
).get_tools(request.query_params.get('folder_id')))
7373

7474
class Debug(APIView):

0 commit comments

Comments
 (0)