Documentation
¶
Index ¶
- Constants
- Variables
- func DataValidate(row []interface{}, value interface{}, rule string) ([]interface{}, bool)
- func ErrorF(format string, data ...interface{}) error
- func GetArrayString(data map[string]interface{}, key string) ([]string, error)
- func GetString(data map[string]interface{}, key string, required bool) (string, error)
- func Load(cfg config.Config)
- func LoadFrom(dir string, prefix string)
- func Open(name string) from.Source
- func ProcessData(process *gou.Process) interface{}
- func ProcessDataSetting(process *gou.Process) interface{}
- func ProcessMapping(process *gou.Process) interface{}
- func ProcessMappingSetting(process *gou.Process) interface{}
- func ProcessRun(process *gou.Process) interface{}
- func ProcessSetting(process *gou.Process) interface{}
- type Binding
- type Column
- type Importer
- func (imp *Importer) AutoMapping(src from.Source) *Mapping
- func (imp *Importer) Chunk(src from.Source, mapping *Mapping, cb func(line int, data [][]interface{}))
- func (imp *Importer) DataClean(data [][]interface{}, bindings []*Binding) ([]string, [][]interface{})
- func (imp *Importer) DataGet(src from.Source, page int, size int, mapping *Mapping) ([]string, [][]interface{})
- func (imp *Importer) DataPreview(src from.Source, page int, size int, mapping *Mapping) map[string]interface{}
- func (imp *Importer) DataSetting() map[string]interface{}
- func (imp *Importer) Fingerprint(src from.Source) string
- func (imp *Importer) MappingPreview(src from.Source) *Mapping
- func (imp *Importer) MappingSetting(src from.Source) map[string]interface{}
- func (imp *Importer) Run(src from.Source, mapping *Mapping) interface{}
- func (imp *Importer) SaveAsTemplate(src from.Source)
- func (imp *Importer) Start()
- type Mapping
- type Option
Constants ¶
const PreviewAlways = "always"
PreviewAlways 一直显示
const PreviewAuto = "auto"
PreviewAuto 一直显示
const PreviewNever = "never"
PreviewNever 从不显示
Variables ¶
var Importers = map[string]*Importer{}
Importers 导入器
Functions ¶
func DataValidate ¶
DataValidate 数值校验
func GetArrayString ¶
GetArrayString 读取字符串数组
func ProcessData ¶
ProcessData xiang.import.Data 数据预览
func ProcessDataSetting ¶
ProcessDataSetting xiang.import.DataSetting 数据预览表格配置
func ProcessMapping ¶
ProcessMapping xiang.import.Mapping 字段映射预览
func ProcessMappingSetting ¶
ProcessMappingSetting xiang.import.MappingSetting 字段映射表格配置
func ProcessRun ¶
ProcessRun xiang.import.Run 导入数据
func ProcessSetting ¶
ProcessSetting xiang.import.Setting 导入配置选项
Types ¶
type Binding ¶
type Binding struct {
Label string `json:"label"` // 目标字段标签
Field string `json:"field"` // 目标字段名称
Name string `json:"name"` // 源关联字段名称
Axis string `json:"axis"` // 源关联字段坐标
Value string `json:"value"` // 示例数据
Rules []string `json:"rules"` // 清洗规则
}
Binding 数据绑定
type Column ¶
type Column struct {
Label string `json:"label"` // 字段标签
Name string `json:"name"` // 字段名称
Field string `json:"field"` // 字段名称(原始值)
Match []string `json:"match,omitempty"` // 匹配建议
Rules []string `json:"rules,omitempty"` // 清洗规则定义
Nullable bool `json:"nullable,omitempty"` // 是否可以为空
Primary bool `json:"primary,omitempty"` // 是否为主键
Key string // 字段键名 Object Only
IsArray bool // 字段是否为 Array
IsObject bool // 字段是否为 Object
}
Column 导入字段定义
func (Column) MarshalJSON ¶
MarshalJSON for json marshalJSON
func (*Column) UnmarshalJSON ¶
UnmarshalJSON for json marshalJSON
type Importer ¶
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"` // 许可导入规则
}
Importer 数据导入器
func (*Importer) AutoMapping ¶
AutoMapping 根据文件信息获取字段映射表
func (*Importer) Chunk ¶
func (imp *Importer) Chunk(src from.Source, mapping *Mapping, cb func(line int, data [][]interface{}))
Chunk 遍历数据
func (*Importer) DataClean ¶
func (imp *Importer) DataClean(data [][]interface{}, bindings []*Binding) ([]string, [][]interface{})
DataClean 清洗数据
func (*Importer) DataGet ¶
func (imp *Importer) DataGet(src from.Source, page int, size int, mapping *Mapping) ([]string, [][]interface{})
DataGet 读取源数据记录
func (*Importer) DataPreview ¶
func (imp *Importer) DataPreview(src from.Source, page int, size int, mapping *Mapping) map[string]interface{}
DataPreview 预览数据
func (*Importer) DataSetting ¶
DataSetting 预览数据表格配置
func (*Importer) Fingerprint ¶
Fingerprint 文件结构指纹
func (*Importer) MappingPreview ¶
MappingPreview 预览字段映射关系
func (*Importer) MappingSetting ¶
MappingSetting 预览映射数据表格配置
func (*Importer) SaveAsTemplate ¶
SaveAsTemplate 保存为映射模板
type Mapping ¶
type Mapping struct {
Sheet string `json:"sheet"` // 数据表
ColStart int `json:"colStart"` // 第一列的位置
RowStart int `json:"rowStart"` // 第一行的位置
Columns []*Binding `json:"data"` // 字段数据列表
AutoMatching bool `json:"autoMatching"` // 是否自动匹配
TemplateMatching bool `json:"templateMatching"` // 是否通过已传模板匹配
}
Mapping 字段映射表
type 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 不显示
}
Option 导入配置项定
func (*Option) UnmarshalJSON ¶
UnmarshalJSON for json marshalJSON