瀏覽代碼

准备开发从mysql->pg的数据抽取

wangxq 3 月之前
父節點
當前提交
6144ac1a8d
共有 2 個文件被更改,包括 12 次插入5 次删除
  1. 4 3
      app/api/data_resource/routes.py
  2. 8 2
      app/core/data_resource/resource.py

+ 4 - 3
app/api/data_resource/routes.py

@@ -187,14 +187,15 @@ def data_resource_save():
             if not storage_location:
                 return jsonify(failed("参数不完整:缺少storage_location或storage_location为空"))
                         
-            # 调用业务逻辑处理数据资源创建
-            resource_id = handle_node(receiver, head_data, data_resource)
+            # 调用业务逻辑处理数据资源创建,设置resource_type为structure
+            resource_id = handle_node(receiver, head_data, data_resource, resource_type='structure')
         elif file_extension == 'sql':
             data_source = receiver['data_source']
             # 如果是ddl,则需要检查data_source是否存在
             if not data_source or (isinstance(data_source, dict) and not data_source.get("en_name")):
                 return jsonify(failed("数据源信息不完整或无效"))
-            resource_id = handle_node(receiver, head_data, data_resource, data_source)
+            # 调用业务逻辑处理数据资源创建,设置resource_type为ddl
+            resource_id = handle_node(receiver, head_data, data_resource, data_source, resource_type='ddl')
         else:
             return jsonify(failed("文件格式错误"))
     

+ 8 - 2
app/core/data_resource/resource.py

@@ -94,14 +94,20 @@ def update_or_create_node(label, **properties):
         return None
 
 # 数据资源-元数据 关系节点创建、查询
-def handle_node(receiver, head_data, data_resource, data_source=None):
+def handle_node(receiver, head_data, data_resource, data_source=None, resource_type=None):
     """处理数据资源节点创建和关系建立"""
     try:
+        # 根据resource_type设置type属性的值
+        if resource_type == 'ddl':
+            type_value = 'ddl'
+        else:
+            type_value = 'structure'
+            
         # 更新属性
         update_attributes = {
             'en_name': data_resource['en_name'],
             'time': get_formatted_time(),
-            'type': 'structure'  # 结构化文件没有type
+            'type': type_value  # 根据资源类型设置不同的type值
         }
         if 'additional_info' in receiver:
             del receiver['additional_info']