+ imports

This commit is contained in:
Max 2022-01-13 19:29:39 +08:00
parent 258457e2bd
commit b6c65a63f1
7 changed files with 123 additions and 0 deletions

1
imports/imports.go Normal file
View file

@ -0,0 +1 @@
package imports

41
imports/types.go Normal file
View file

@ -0,0 +1,41 @@
package imports
import "github.com/yaoapp/gou"
// PreviewAuto 一直显示
const PreviewAuto = "auto"
// PreviewAlways 一直显示
const PreviewAlways = "always"
// PreviewNever 从不显示
const PreviewNever = "never"
// Imports 数据导入
type Imports struct {
Title string `json:"title,omitempty"` // 导入名称
Process *gou.Process `json:"process"` // 处理器名称
Columns []Column `json:"columns"` // 字段列表
Option Option `json:"option,omitempty"` // 导入配置项
}
// Column 导入字段定义
type Column struct {
Label string `json:"label"` // 字段标签
Name string `json:"name"` // 字段名称
Match []string `json:"match,omitempty"` // 匹配建议
Rules []gou.Process `json:"rules,omitempty"` // 清洗规则定义
Nullable bool `json:"nullable,omitempty"` // 是否可以为空
Key string // 字段键名 Object Only
IsArray bool // 字段是否为 Array
IsObject bool // 字段是否为 Object
}
// Option 导入配置项定
type Option struct {
AutoMatching bool `json:"autoMatching,omitempty"` // 是否自动匹配已设定模板
ChunkSize int `json:"chunkSize,omitempty"` // 每次处理记录数量
MappingPreview string `json:"mappingPreview,omitempty"` // 显示字段映射界面方式 auto 匹配模板失败显示, always 一直显示, never 不显示
DataPreview string `json:"dataPreview,omitempty"` // 数据预览界面方式 auto 有异常数据时显示, always 一直显示, never 不显示
}

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,5 @@
订单号,姓名,手机,性别,年龄,商品名称,数量,单价,总价,备注
SN202101120018,张三,13211000011,,26,彩绘湖北地图,3,65.5,196.5,
,李四,13211000011,,42,景祐遁甲符应经,1,34.8,34.8,
SN202101120019,王二麻子,13410001998,,51,太极先天后天三图说,1,24.35,72.85,孔夫子二手交易
SN202101120019,王二麻子,13410001998,,51,五要奇书,1,48.5,72.85,孔夫子二手交易
1 订单号 姓名 手机 性别 年龄 商品名称 数量 单价 总价 备注
2 SN202101120018 张三 13211000011 26 彩绘湖北地图 3 65.5 196.5
3 李四 13211000011 42 景祐遁甲符应经 1 34.8 34.8
4 SN202101120019 王二麻子 13410001998 51 太极先天后天三图说 1 24.35 72.85 孔夫子二手交易
5 SN202101120019 王二麻子 13410001998 51 五要奇书 1 48.5 72.85 孔夫子二手交易

Binary file not shown.

View file

@ -0,0 +1,76 @@
{
"title": "导入订单数据",
"process": "flows.order.Import",
"columns": [
{
"label": "订单号",
"name": "order_sn",
"match": ["订单号", "订单", "order_sn", "id"],
"rules": ["scripts.rules.order_sn"],
"primary": true
},
{
"label": "用户",
"name": "user.name",
"match": ["用户名称", "姓名", "user_id"],
"rules": ["scripts.rules.FmtUser"],
"nullable": true
},
{
"label": "性别",
"name": "user.sex",
"match": ["性别", "gender", "sex"],
"rules": ["scripts.rules.FmtUser"],
"nullable": true
},
{
"label": "年龄",
"name": "user.age",
"match": ["年龄", "age"],
"rules": ["scripts.rules.FmtUser"],
"nullable": true
},
{
"label": "手机号",
"name": "mobile",
"match": ["手机号", "手机", "mobile"],
"rules": ["scripts.rules.mobile"]
},
{
"label": "商品",
"name": "skus[*].name",
"match": ["商品", "商品名称", "goods", "skus", "sku_id", "goods_id"],
"rules": ["scripts.rules.FmtGoods"]
},
{
"label": "数量",
"name": "skus[*].amount",
"match": ["数量", "amount"],
"rules": ["scripts.rules.FmtGoods"]
},
{
"label": "单价",
"name": "skus[*].price",
"match": ["单价", "price", "价格"],
"rules": ["scripts.rules.FmtGoods"]
},
{
"label": "总价",
"name": "total",
"match": ["总价", "total", "total_price"],
"rules": ["scripts.rules.FmtGoods"]
},
{
"label": "备注",
"name": "remark",
"match": ["备注", "说明", "其他"]
}
],
"option": {
"autoMatching": true,
"chunkSize": 500,
"logging": "error",
"mappingPreview": "auto",
"dataPreview": "auto"
}
}