diff --git a/apps/system_manage/serializers/resource_mapping_serializers.py b/apps/system_manage/serializers/resource_mapping_serializers.py index cdc2126bd46..2ee4634b5c9 100644 --- a/apps/system_manage/serializers/resource_mapping_serializers.py +++ b/apps/system_manage/serializers/resource_mapping_serializers.py @@ -21,13 +21,19 @@ class ResourceMappingSerializer(serializers.Serializer): resource = serializers.CharField(required=True, label=_('resource')) resource_id = serializers.UUIDField(required=True, label=_('resource Id')) - resource_name = serializers.CharField(required=False, allow_null=True, allow_blank=True, label=_('resource')) + resource_name = serializers.CharField(required=False, allow_null=True, allow_blank=True, label=_('resource Name')) + source_type = serializers.ListField( + label=_('source Type'), + child=serializers.CharField(required=False, allow_null=True, allow_blank=True, label=_('source Type'))) + user_name = serializers.CharField(required=False, allow_null=True, allow_blank=True, label=_('creator')) def get_query_set(self): queryset = QuerySet(model=get_dynamics_model({ 'name': models.CharField(), 'target_id': models.CharField(), - "target_type": models.CharField() + "target_type": models.CharField(), + "u.username": models.CharField(), + 'rm.source_type': models.CharField() })) queryset = queryset.filter(target_id=self.data.get('resource_id'), @@ -35,7 +41,10 @@ def get_query_set(self): if self.data.get('resource_name'): queryset = queryset.filter(name__icontains=self.data.get('resource_name')) - + if self.data.get('user_name'): + queryset = queryset.filter(**{'u.username__icontains': self.data.get('user_name')}) + if self.data.get("source_type"): + queryset = queryset.filter(**{'rm.source_type__in': self.data.get('source_type')}) return queryset def page(self, current_page, page_size): diff --git a/apps/system_manage/sql/list_resource_mapping.sql b/apps/system_manage/sql/list_resource_mapping.sql index 3c6a106e700..904ea127c38 100644 --- a/apps/system_manage/sql/list_resource_mapping.sql +++ b/apps/system_manage/sql/list_resource_mapping.sql @@ -1,12 +1,13 @@ -WITH source_data_cte AS ( - SELECT 'APPLICATION' as source_type, id, "name", "desc","user_id" - FROM application - UNION ALL - SELECT 'KNOWLEDGE' as source_type, id, "name", "desc","user_id" - FROM knowledge) +WITH source_data_cte AS (SELECT 'APPLICATION' as source_type, id, "name", "desc", "user_id" + FROM application + UNION ALL + SELECT 'KNOWLEDGE' as source_type, id, "name", "desc", "user_id" + FROM knowledge) SELECT rm.*, - sdc.* + sdc.*, + u.username as username FROM resource_mapping rm LEFT JOIN source_data_cte sdc ON rm.source_type = sdc.source_type - AND rm.source_id::uuid = sdc.id \ No newline at end of file + AND rm.source_id::uuid = sdc.id + LEFT JOIN "public"."user" u on u.id = sdc.user_id \ No newline at end of file diff --git a/apps/system_manage/views/resource_mapping.py b/apps/system_manage/views/resource_mapping.py index a0aeb005a3e..08a8e60b03e 100644 --- a/apps/system_manage/views/resource_mapping.py +++ b/apps/system_manage/views/resource_mapping.py @@ -33,5 +33,7 @@ def get(self, request: Request, workspace_id: str, resource: str, resource_id: s return result.success(ResourceMappingSerializer({ 'resource': resource, 'resource_id': resource_id, - 'resource_name': request.query_params.get('resource_name') + 'resource_name': request.query_params.get('resource_name'), + 'user_name': request.query_params.get('user_name'), + 'source_type': request.query_params.getlist('source_type[]'), }).page(current_page, page_size)) diff --git a/ui/src/components/app-icon/icons/system.ts b/ui/src/components/app-icon/icons/system.ts index 61561124d3e..4e90672cf9d 100644 --- a/ui/src/components/app-icon/icons/system.ts +++ b/ui/src/components/app-icon/icons/system.ts @@ -81,4 +81,37 @@ export default { ]) }, }, + + 'app-resource-mapping': { + iconReader: () => { + return h('i', [ + h( + 'svg', + { + viewBox: '0 0 16 16', + version: '1.1', + xmlns: 'http://www.w3.org/2000/svg', + }, + [ + h('path', { + d: 'M3.64023 7.55547C4.16284 6.83981 4.62542 5.57247 5.08688 3.7308C5.35033 2.67938 5.67074 2.22214 5.94869 2.22214C6.19415 2.22214 6.39314 2.02316 6.39314 1.7777C6.39314 1.53224 6.19415 1.33325 5.94869 1.33325C5.11916 1.33325 4.57762 2.10607 4.22465 3.51476C3.8289 5.09417 3.42652 6.20022 3.07385 6.81123C2.9227 6.71944 2.74528 6.66658 2.55552 6.66658H1.88886C1.33657 6.66658 0.888855 7.1143 0.888855 7.66658V8.33325C0.888855 8.88554 1.33657 9.33325 1.88886 9.33325H2.55552C2.72067 9.33325 2.87647 9.29322 3.01375 9.22232C3.33858 9.88602 3.69875 10.9575 4.05283 12.4188C4.40498 13.8722 4.9433 14.6666 5.7777 14.6666C6.02316 14.6666 6.22214 14.4676 6.22214 14.2221C6.22214 13.9767 6.02316 13.7777 5.7777 13.7777C5.50461 13.7777 5.18098 13.3001 4.91672 12.2095C4.49159 10.455 4.06638 9.20685 3.59354 8.44436H6.46662C6.57707 8.44436 6.66662 8.35482 6.66662 8.24436V7.75547C6.66662 7.64502 6.57707 7.55547 6.46662 7.55547H3.64023Z', + fill: '#646A73', + }), + h('path', { + d: 'M7.99998 2.11103C7.99998 1.92694 8.14922 1.7777 8.33332 1.7777H14.7778C14.9619 1.7777 15.1111 1.92693 15.1111 2.11103V3.22214C15.1111 3.40624 14.9619 3.55547 14.7778 3.55547H8.33332C8.14922 3.55547 7.99998 3.40624 7.99998 3.22214V2.11103Z', + fill: '#646A73', + }), + h('path', { + d: 'M8.33332 7.11103C8.14922 7.11103 7.99998 7.26027 7.99998 7.44436V8.55547C7.99998 8.73957 8.14922 8.88881 8.33332 8.88881H14.7778C14.9619 8.88881 15.1111 8.73957 15.1111 8.55547V7.44436C15.1111 7.26027 14.9619 7.11103 14.7778 7.11103H8.33332Z', + fill: '#646A73', + }), + h('path', { + d: 'M7.99998 12.7777C7.99998 12.5936 8.14922 12.4444 8.33332 12.4444H14.7778C14.9619 12.4444 15.1111 12.5936 15.1111 12.7777V13.8888C15.1111 14.0729 14.9619 14.2221 14.7778 14.2221H8.33332C8.14922 14.2221 7.99998 14.0729 7.99998 13.8888V12.7777Z', + fill: '#646A73', + }), + ], + ), + ]) + }, + }, } diff --git a/ui/src/components/resource_mapping/index.vue b/ui/src/components/resource_mapping/index.vue index 08f8ad557a9..68d2247bc72 100644 --- a/ui/src/components/resource_mapping/index.vue +++ b/ui/src/components/resource_mapping/index.vue @@ -1,7 +1,7 @@ @@ -60,6 +83,8 @@ const { user } = useStore() const searchType = ref('resource_name') const query = ref({ resource_name: '', + user_name: '', + source_type: '', }) const loading = ref(false) const tableData = ref>() diff --git a/ui/src/views/knowledge/component/KnowledgeListContainer.vue b/ui/src/views/knowledge/component/KnowledgeListContainer.vue index fbb575c339f..81783077be6 100644 --- a/ui/src/views/knowledge/component/KnowledgeListContainer.vue +++ b/ui/src/views/knowledge/component/KnowledgeListContainer.vue @@ -239,6 +239,13 @@ > {{ $t('views.system.resourceAuthorization.title') }} + + + {{ $t('views.system.resourceMapping.title', '查看关联资源') }} + +