Commit 61c88dd3 by liyijie

feat: 导入顺序,按照headers里面定义的顺序处理

parent 9816c47b
...@@ -105,13 +105,13 @@ module TalltyImportExport ...@@ -105,13 +105,13 @@ module TalltyImportExport
end end
def convert_data line_info def convert_data line_info
line_info.with_indifferent_access.reduce({}) do |h, (k, v)| info = line_info.with_indifferent_access
header = import_headers_result.find do |_header| import_headers_result.reduce({}) do |h, _header|
_header[:key].to_sym == k.to_sym k = _header[:key]
end v = info[k]
# header[:convert] = handle_xxx # header[:convert] = handle_xxx
# handle_xxx(val, processing_line_info, raw_line_info) # handle_xxx(val, processing_line_info, raw_line_info)
val = header[:convert] ? send(header[:convert], v, h, line_info) : v val = header[:convert] ? send(header[:convert], v, h, info) : v
if header[:json] if header[:json]
h[header[:json]] ||= {} h[header[:json]] ||= {}
h[header[:json]][k] = val h[header[:json]][k] = val
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment