Skip to content

Commit

Permalink
+ Import API & 处理器
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Jan 18, 2022
1 parent 7f5d9e9 commit 5da0b00
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 0 deletions.
49 changes: 49 additions & 0 deletions importer/process.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package importer

import "github.com/yaoapp/gou"

func init() {
// 注册处理器
gou.RegisterProcessHandler("xiang.import.Run", ProcessRun)
gou.RegisterProcessHandler("xiang.import.Data", ProcessData)
gou.RegisterProcessHandler("xiang.import.DataSetting", ProcessDataSetting)
gou.RegisterProcessHandler("xiang.import.Mapping", ProcessMapping)
gou.RegisterProcessHandler("xiang.import.MappingSetting", ProcessMappingSetting)
gou.RegisterProcessHandler("xiang.import.Rules", ProcessRules)
}

// ProcessRun xiang.import.Run
// 导入数据
func ProcessRun(process *gou.Process) interface{} {
return nil
}

// ProcessData xiang.import.Data
// 数据预览
func ProcessData(process *gou.Process) interface{} {
return nil
}

// ProcessDataSetting xiang.import.DataSetting
// 数据预览表格配置
func ProcessDataSetting(process *gou.Process) interface{} {
return nil
}

// ProcessMapping xiang.import.Mapping
// 字段映射预览
func ProcessMapping(process *gou.Process) interface{} {
return nil
}

// ProcessMappingSetting xiang.import.MappingSetting
// 字段映射表格配置
func ProcessMappingSetting(process *gou.Process) interface{} {
return nil
}

// ProcessRules xiang.import.Rules
// 可用处理器下拉列表
func ProcessRules(process *gou.Process) interface{} {
return nil
}
38 changes: 38 additions & 0 deletions importer/process_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package importer

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/yaoapp/gou"
)

func TestProcessMapping(t *testing.T) {
args := []interface{}{"order"}
response := gou.NewProcess("xiang.import.Mapping", args...).Run()
assert.Nil(t, response)
}

func TestProcessMappingSetting(t *testing.T) {
args := []interface{}{"order"}
response := gou.NewProcess("xiang.import.MappingSetting", args...).Run()
assert.Nil(t, response)
}

func TestProcessData(t *testing.T) {
args := []interface{}{"order"}
response := gou.NewProcess("xiang.import.Data", args...).Run()
assert.Nil(t, response)
}

func TestProcessDataSetting(t *testing.T) {
args := []interface{}{"order"}
response := gou.NewProcess("xiang.import.DataSetting", args...).Run()
assert.Nil(t, response)
}

func TestProcessRules(t *testing.T) {
args := []interface{}{"order"}
response := gou.NewProcess("xiang.import.Rules", args...).Run()
assert.Nil(t, response)
}
69 changes: 69 additions & 0 deletions xiang/apis/import.http.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "数据导入接口",
"version": "1.0.0",
"description": "数据分析接口API",
"group": "xiang/import",
"guard": "bearer-jwt",
"paths": [
{
"path": "/:name",
"method": "POST",
"process": "xiang.import.Run",
"in": ["$param.name", ":payload"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/data",
"method": "POST",
"process": "xiang.import.Data",
"in": ["$param.name", ":payload"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/data/setting",
"method": "GET",
"process": "xiang.import.DataSetting",
"in": ["$param.name", ":query"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/mapping",
"method": "GET",
"process": "xiang.import.Mapping",
"in": ["$param.name", ":query"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/mapping/setting",
"method": "GET",
"process": "xiang.import.MappingSetting",
"in": ["$param.name", ":query"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/:name/rule/select",
"method": "GET",
"process": "xiang.import.Rules",
"in": ["$param.name", ":query"],
"out": {
"status": 200,
"type": "application/json"
}
}
]
}

0 comments on commit 5da0b00

Please sign in to comment.