database/define/api2sql.go

41 lines
2.0 KiB
Go
Raw Normal View History

// Package define ...
//
// Description : define ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2024-08-21 16:05
package define
// Api2SqlParam 接口转sql的输入配置
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 16:06 2024/8/21
type Api2SqlParam struct {
2024-08-21 21:01:39 +08:00
DatabaseFlag string `json:"database_flag"` // 数据库标识
2024-08-21 16:35:46 +08:00
InputSql string `json:"input_sql"` // 输入的sql模板, 仅依赖 ValueList 解析字段值, 依赖 split 相关解析分表配置
TableSplit bool `json:"table_split"` // 是否分表
SplitField string `json:"split_field"` // 分表字段, 仅分表时有效, 分表字段要求在 ValueList 必须存在
SplitStrategy string `json:"split_strategy"` // 分表策略, 仅分表时有效, 支持注册自动以策略
SqlType string `json:"sql_type"` // sql语句类型 : detail - 查询详情 list - 查询列表 count - 查询数量 update - 更新 insert - 插入 delete - 删除
2024-08-21 21:11:19 +08:00
FieldList []string `json:"field_list"` // 仅针对 select / detail 有效, 查询的字段列表
OrderField string `json:"order_field"` // 排序字段, 仅 sqlType = list 生效
OrderRule string `json:"order_rule"` // 排序规则, Asc / Desc
WithCount bool `json:"with_count"` // 是否返回数据总量, 仅 sqlType = list 生效
ValueList []*Api2SqlParamValue `json:"value_list"` // 字段列表
}
// Api2SqlParamValue ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 16:11 2024/8/21
type Api2SqlParamValue struct {
Field string `json:"field"` // 表字段
Value any `json:"value"` // 数据字段的值
OutputName string `json:"output_name"` // 字段对外输出的名字, 不配置, 默认 与 Field 一致
Default any `json:"-"` // 默认值 TODO : 配置默认值生成策略
DataMask any `json:"-"` // 数据脱敏策略
}