2
This commit is contained in:
@@ -91,10 +91,6 @@ func (r *DatabaseTableReader) ReadTableFromDocumentation(ctx context.Context, do
|
||||
}
|
||||
|
||||
// 如果不是JSON格式,先解析为markdown表格,然后转换为JSON格式
|
||||
r.logger.Info("开始解析markdown表格并转换为JSON",
|
||||
zap.String("field_type", fieldType),
|
||||
zap.Int("content_length", len(content)),
|
||||
zap.String("content_preview", r.getContentPreview(content, 200)))
|
||||
|
||||
tableData, err := r.parseMarkdownTable(content)
|
||||
if err != nil {
|
||||
@@ -102,20 +98,10 @@ func (r *DatabaseTableReader) ReadTableFromDocumentation(ctx context.Context, do
|
||||
return nil, fmt.Errorf("解析markdown表格失败: %w", err)
|
||||
}
|
||||
|
||||
r.logger.Info("markdown表格解析成功",
|
||||
zap.String("field_type", fieldType),
|
||||
zap.Int("header_count", len(tableData.Headers)),
|
||||
zap.Int("row_count", len(tableData.Rows)),
|
||||
zap.Strings("headers", tableData.Headers))
|
||||
|
||||
// 将markdown表格数据转换为JSON格式(保持列顺序)
|
||||
r.logger.Debug("开始将表格数据转换为JSON格式", zap.String("field_type", fieldType))
|
||||
jsonArray = r.convertTableDataToJSON(tableData)
|
||||
|
||||
r.logger.Info("表格数据已转换为JSON格式",
|
||||
zap.String("field_type", fieldType),
|
||||
zap.Int("json_array_length", len(jsonArray)))
|
||||
|
||||
// 记录转换后的JSON(用于调试)
|
||||
jsonBytes, marshalErr := json.MarshalIndent(jsonArray, "", " ")
|
||||
if marshalErr != nil {
|
||||
@@ -422,9 +408,6 @@ func (r *DatabaseTableReader) parseMarkdownTablesWithTitles(content string) ([]T
|
||||
return nil, fmt.Errorf("无法解析表格:未找到表头")
|
||||
}
|
||||
|
||||
r.logger.Info("解析多个表格完成",
|
||||
zap.Int("table_count", len(result)))
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user