+ setting API
This commit is contained in:
parent
b9b6a52cb0
commit
c4e2ab2c7a
5 changed files with 34 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ func init() {
|
|||
// 注册处理器
|
||||
gou.RegisterProcessHandler("xiang.import.Run", ProcessRun)
|
||||
gou.RegisterProcessHandler("xiang.import.Data", ProcessData)
|
||||
gou.RegisterProcessHandler("xiang.import.Setting", ProcessSetting)
|
||||
gou.RegisterProcessHandler("xiang.import.DataSetting", ProcessDataSetting)
|
||||
gou.RegisterProcessHandler("xiang.import.Mapping", ProcessMapping)
|
||||
gou.RegisterProcessHandler("xiang.import.MappingSetting", ProcessMappingSetting)
|
||||
|
|
@ -28,6 +29,19 @@ func ProcessRun(process *gou.Process) interface{} {
|
|||
return imp.Run(src, mapping)
|
||||
}
|
||||
|
||||
// ProcessSetting xiang.import.Setting
|
||||
// 导入配置选项
|
||||
func ProcessSetting(process *gou.Process) interface{} {
|
||||
process.ValidateArgNums(1)
|
||||
name := process.ArgsString(0)
|
||||
imp := Select(name)
|
||||
return map[string]interface{}{
|
||||
"mappingPreview": imp.Option.MappingPreview,
|
||||
"dataPreview": imp.Option.DataPreview,
|
||||
"title": imp.Title,
|
||||
}
|
||||
}
|
||||
|
||||
// ProcessData xiang.import.Data
|
||||
// 数据预览
|
||||
func ProcessData(process *gou.Process) interface{} {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,13 @@ func TestProcessDataSetting(t *testing.T) {
|
|||
assert.True(t, ok)
|
||||
}
|
||||
|
||||
func TestProcessSetting(t *testing.T) {
|
||||
args := []interface{}{"order"}
|
||||
response := gou.NewProcess("xiang.import.Setting", args...).Run()
|
||||
_, ok := response.(map[string]interface{})
|
||||
assert.True(t, ok)
|
||||
}
|
||||
|
||||
func TestProcessRun(t *testing.T) {
|
||||
simple := filepath.Join(config.Conf.Root, "imports", "assets", "simple.xlsx")
|
||||
mapping := gou.NewProcess("xiang.import.Mapping", "order", simple).Run()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ type Column struct {
|
|||
// Option 导入配置项定
|
||||
type Option struct {
|
||||
UseTemplate bool `json:"useTemplate,omitempty"` // 使用已匹配过的模板
|
||||
TemplateLink string `json:"templateLink,omitempty"` // 默认数据模板链接
|
||||
ChunkSize int `json:"chunkSize,omitempty"` // 每次处理记录数量
|
||||
MappingPreview string `json:"mappingPreview,omitempty"` // 显示字段映射界面方式 auto 匹配模板失败显示, always 一直显示, never 不显示
|
||||
DataPreview string `json:"dataPreview,omitempty"` // 数据预览界面方式 auto 有异常数据时显示, always 一直显示, never 不显示
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@
|
|||
"chunkSize": 3,
|
||||
"logging": "error",
|
||||
"mappingPreview": "auto",
|
||||
"dataPreview": "auto"
|
||||
"dataPreview": "auto",
|
||||
"templateLink": "/somelinke/download/xxx"
|
||||
},
|
||||
"rules": {
|
||||
"scripts.rules.order_sn": "订单号验证",
|
||||
|
|
|
|||
|
|
@ -15,6 +15,16 @@
|
|||
"type": "application/json"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/:name/setting",
|
||||
"method": "GET",
|
||||
"process": "xiang.import.Setting",
|
||||
"in": ["$param.name"],
|
||||
"out": {
|
||||
"status": 200,
|
||||
"type": "application/json"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/:name/data",
|
||||
"method": "POST",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue