rulechain.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package models
  2. import (
  3. "errors"
  4. "github.com/jinzhu/gorm"
  5. )
  6. // RuleChain 规则链
  7. type RuleChain struct {
  8. gorm.Model
  9. RecordId string `gorm:"column:record_id;size:32;index"`
  10. AdditionalInfo string `gorm:"column:additional_info"` //节点属性信息
  11. Configuration string `gorm:"column:configuration"` //配置信息
  12. Name string `gorm:"column:name"` //名称
  13. FirstRuleNodeID string `gorm:"column:first_rule_node_id"` //第一个节点的ID
  14. Root bool `gorm:"column:root"` //是否为root chain
  15. DebugModel bool `gorm:"column:debug_model"` //调试模式
  16. Intro string `gorm:"column:intro"` //描述
  17. VendorID string `gorm:"column:vendor_id"` //厂商ID
  18. }
  19. type Cells []*Cell
  20. type Cell struct {
  21. Id string `json:"id"` // id
  22. Data CellData `json:"data"` // 数据
  23. }
  24. type CellData struct {
  25. Name string `json:"name"` // 名称
  26. Id string `json:"id"` // id
  27. Type string `json:"type"` // 节点类型
  28. Desc string `json:"desc"` // 备注
  29. ZIndex string `json:"ZIndex"` // 序号
  30. Shape string `json:"shape"` // 类型
  31. FuncBody string `json:"func_body"` // 代码
  32. Labels []string `json:"labels"`
  33. Source string `json:"source"` // 源节点id
  34. Target string `json:"target"` // 目标节点id
  35. Headers []*Headers `json:"headers"`
  36. }
  37. type NodeConfiguration struct {
  38. Url string `json:"url"`
  39. Method string `json:"method"`
  40. Headers map[string]string `json:"headers"`
  41. Retry int `json:"retry"`
  42. TimeOut int `json:"time_out"`
  43. RetryWait int `json:"retry_wait"`
  44. }
  45. type Headers struct {
  46. Key string `json:"key"`
  47. Value string `json:"value"`
  48. }
  49. // Validate ``
  50. func (a *RuleChain) Validate() error {
  51. if a.Name == "" {
  52. return errors.New("规则链名称为空")
  53. }
  54. return nil
  55. }