{
  "修复说明": "DDL Parse API 格式修复 - 符合参考文档 DDLparse格式.txt",
  
  "参考格式_单表": {
    "说明": "来自 docs/DDLparse格式.txt",
    "格式": {
      "code": 200,
      "data": {
        "table_info": {
          "name_zh": "科室对照表",
          "name_en": "TB_JC_KSDZB"
        },
        "columns": [
          {
            "name_zh": "医疗机构代码",
            "name_en": "YLJGDM",
            "data_type": "VARCHAR(22)",
            "is_primary": "是",
            "comment": "医疗机构代码，复合主键",
            "nullable": "否"
          }
        ]
      },
      "message": "操作成功"
    }
  },
  
  "修复后格式_单表": {
    "说明": "修复后的格式，使用数组返回，单表也是数组格式",
    "格式": {
      "code": 200,
      "data": [
        {
          "table_info": {
            "name_zh": "科室对照表",
            "name_en": "TB_JC_KSDZB"
          },
          "columns": [
            {
              "name_zh": "医疗机构代码",
              "name_en": "YLJGDM",
              "data_type": "VARCHAR(22)",
              "is_primary": "是",
              "comment": "医疗机构代码，复合主键",
              "nullable": "否"
            },
            {
              "name_zh": "HIS科室代码",
              "name_en": "HISKSDM",
              "data_type": "CHAR(20)",
              "is_primary": "是",
              "comment": "HIS科室代码，主键、唯一",
              "nullable": "否"
            },
            {
              "name_zh": "HIS科室名称",
              "name_en": "HISKSMC",
              "data_type": "CHAR(20)",
              "is_primary": "否",
              "comment": "HIS科室名称",
              "nullable": "否"
            }
          ]
        }
      ],
      "message": "操作成功"
    }
  },
  
  "修复后格式_多表": {
    "说明": "修复后的格式，使用数组返回多个表，不使用表名作为key",
    "格式": {
      "code": 200,
      "data": [
        {
          "table_info": {
            "name_zh": "科室对照表",
            "name_en": "TB_JC_KSDZB"
          },
          "columns": [
            {
              "name_zh": "医疗机构代码",
              "name_en": "YLJGDM",
              "data_type": "VARCHAR(22)",
              "is_primary": "是",
              "comment": "医疗机构代码，复合主键",
              "nullable": "否"
            }
          ]
        },
        {
          "table_info": {
            "name_zh": "用户表",
            "name_en": "TB_USER"
          },
          "columns": [
            {
              "name_zh": "用户ID",
              "name_en": "USER_ID",
              "data_type": "INTEGER",
              "is_primary": "是",
              "comment": "用户唯一标识",
              "nullable": "否"
            }
          ]
        }
      ],
      "message": "操作成功"
    }
  },
  
  "关键改进": [
    "✅ 1. 删除了冲突的 system message，统一使用 _optimize_ddl_prompt()",
    "✅ 2. 添加了缺失的字段：is_primary, comment, nullable",
    "✅ 3. 使用 table_info + columns 结构（符合参考格式）",
    "✅ 4. 保持表名和字段名原始大小写",
    "✅ 5. 使用JSON数组格式返回，不使用表名作为key",
    "✅ 6. 支持单表和多表，统一返回数组格式"
  ],
  
  "字段说明": {
    "table_info.name_zh": "表的中文名称，从COMMENT ON TABLE提取",
    "table_info.name_en": "表的英文名称，保持原始大小写",
    "columns[].name_zh": "字段中文名称，从COMMENT ON COLUMN提取",
    "columns[].name_en": "字段英文名称，保持原始大小写",
    "columns[].data_type": "数据类型，包含长度信息（如VARCHAR(22)）",
    "columns[].is_primary": "是否主键，取值：是/否",
    "columns[].comment": "完整的注释内容",
    "columns[].nullable": "是否可为空，取值：是/否（根据NOT NULL约束判断）"
  },
  
  "修改文件": [
    "app/core/llm/ddl_parser.py - parse_ddl() 方法",
    "app/core/llm/ddl_parser.py - _optimize_ddl_prompt() 方法"
  ]
}

