|
24 | 24 | from common.utils.common import get_file_content |
25 | 25 | from knowledge.serializers.common import BatchSerializer |
26 | 26 | from maxkb.conf import PROJECT_DIR |
27 | | -from tools.models import Tool |
| 27 | +from tools.models import Tool, ToolWorkflow |
28 | 28 | from trigger.models import TriggerTypeChoices, Trigger, TriggerTaskTypeChoices, TriggerTask, TaskRecord |
29 | 29 |
|
30 | 30 |
|
@@ -605,8 +605,24 @@ def one(self, with_valid=True): |
605 | 605 | tool_task_list = [] |
606 | 606 | if tool_ids: |
607 | 607 | tools = Tool.objects.filter(workspace_id=workspace_id, id__in=tool_ids) |
608 | | - tool_task_list = ToolTriggerTaskSerializer(tools, many=True).data |
609 | | - |
| 608 | + workflows = ToolWorkflow.objects.filter( |
| 609 | + tool_id__in=tools.filter(tool_type='WORKFLOW').values_list('id', flat=True), |
| 610 | + is_publish=True |
| 611 | + ) |
| 612 | + workflow_dict = {wf.tool_id: wf.work_flow for wf in workflows} |
| 613 | + tool_task_list = [] |
| 614 | + for tool in tools: |
| 615 | + tool_data = { |
| 616 | + 'id': str(tool.id), |
| 617 | + 'name': tool.name, |
| 618 | + 'input_field_list': tool.input_field_list, |
| 619 | + 'icon': tool.icon, |
| 620 | + 'tool_type': tool.tool_type |
| 621 | + } |
| 622 | + # 如果是工作流类型,添加 work_flow 字段 |
| 623 | + if tool.tool_type == 'WORKFLOW': |
| 624 | + tool_data['work_flow'] = workflow_dict.get(tool.id) |
| 625 | + tool_task_list.append(tool_data) |
610 | 626 | return { |
611 | 627 | **TriggerModelSerializer(trigger).data, |
612 | 628 | 'trigger_task': trigger_task_list, |
|
0 commit comments