diff --git a/importer/importer.go b/importer/importer.go index 30b594b7..6cdf1fce 100644 --- a/importer/importer.go +++ b/importer/importer.go @@ -382,7 +382,7 @@ func (imp *Importer) SaveAsTemplate(src from.Source) { } // Run 运行导入 -func (imp *Importer) Run(src from.Source, mapping *Mapping) map[string]int { +func (imp *Importer) Run(src from.Source, mapping *Mapping) interface{} { if mapping == nil { mapping = imp.AutoMapping(src) } @@ -424,12 +424,24 @@ func (imp *Importer) Run(src from.Source, mapping *Mapping) map[string]int { log.With(log.F{"line": line, "response": response, "length": length}).Error("导入处理器未返回失败结果") }) - return map[string]int{ + + output := map[string]int{ "total": total, "success": total - failed - ignore, "failure": failed, "ignore": ignore, } + + if imp.Output != "" { + res, err := gou.NewProcess(imp.Output, output).Exec() + if err != nil { + log.With(log.F{"output": imp.Output}).Error(err.Error()) + return output + } + return res + } + + return output } // Start 运行导入(异步) diff --git a/importer/importer_test.go b/importer/importer_test.go index 540aa173..d9d13184 100644 --- a/importer/importer_test.go +++ b/importer/importer_test.go @@ -89,7 +89,7 @@ func TestRunSimple(t *testing.T) { imp := Select("order") mapping := imp.AutoMapping(file) - res := imp.Run(file, mapping) + res := imp.Run(file, mapping).(map[string]int) assert.Equal(t, 1, res["ignore"]) assert.Equal(t, 1, res["failure"]) assert.Equal(t, 2, res["success"]) diff --git a/importer/types.go b/importer/types.go index a574a537..db0ca322 100644 --- a/importer/types.go +++ b/importer/types.go @@ -13,6 +13,7 @@ const PreviewNever = "never" type Importer struct { Title string `json:"title,omitempty"` // 导入名称 Process string `json:"process"` // 处理器名称 + Output string `json:"output,omitempty"` // The process import output Columns []Column `json:"columns"` // 字段列表 Option Option `json:"option,omitempty"` // 导入配置项 Rules map[string]string `json:"rules,omitempty"` // 许可导入规则