package models import ( "errors" "github.com/gogf/gf/encoding/gjson" "github.com/jinzhu/gorm" ) // RuleChain 规则链 type RuleChain struct { gorm.Model RecordId string `gorm:"column:record_id;size:32;index"` AdditionalInfo string `gorm:"column:additional_info"` //节点属性信息 Configuration string `gorm:"column:configuration"` //配置信息 Name string `gorm:"column:name"` //名称 FirstRuleNodeID string `gorm:"column:first_rule_node_id"` //第一个节点的ID Root bool `gorm:"column:root"` //是否为root chain DebugModel bool `gorm:"column:debug_model"` //调试模式 Intro string `gorm:"column:intro"` //描述 VendorID string `gorm:"column:vendor_id"` //厂商ID } // RuleChainParams 更新规则链参数 type RuleChainParams struct { VendorId string `json:"VendorID"` // 厂商id RecordId string `json:"RecordId"` // 记录id Cell []*gjson.Json `json:"cell"` Cells []*Cell } // ChangeRootParams 更新规则链参数 type ChangeRootParams struct { VendorId string `json:"vendor_id"` // 厂商id RecordId string `json:"record_id"` // 记录id Root bool `json:"root"` } type CreatChainReq struct { RecordId string `json:"record_id"` Name string `json:"name"` Cell Cells `json:"cells"` } type Cells []*Cell type Cell struct { Id string `json:"id"` // id Shape string `json:"shape"` Data CellData `json:"data"` // 数据 Source Branch `json:"source"` // 上级节点 Target Branch `json:"target"` // 下级节点 } type CellData struct { Name string `json:"name"` // 名称 Id string `json:"id"` // id Type string `json:"type"` // 节点类型 Desc string `json:"desc"` // 备注 ZIndex string `json:"ZIndex"` // 序号 FuncBody string `json:"func_body"` // 代码 Label string `json:"label"` Source string `json:"source"` // 源节点id Target string `json:"target"` // 目标节点id MesType []string `json:"mes_type"` // 消息类型 Headers []*Headers `json:"headers"` Url string `json:"url"` Method string `json:"method"` Retry int `json:"retry"` TimeOut int `json:"time_out"` RetryWait int `json:"retry_wait"` } type NodeConfiguration struct { Url string `json:"url"` Method string `json:"method"` Headers map[string]interface{} `json:"headers"` Retry int `json:"retry"` TimeOut int `json:"time_out"` RetryWait int `json:"retry_wait"` } type Headers struct { Key string `json:"key"` Value string `json:"value"` } type Branch struct { Cell string `json:"cell"` } // Validate `` func (a *RuleChain) Validate() error { if a.Name == "" { return errors.New("规则链名称为空") } return nil } // Validate `` func (a *RuleChainParams) Validate() error { return nil } // Validate `` func (a *ChangeRootParams) Validate() error { if a.RecordId == "" { return errors.New("记录id不能为空") } return nil }