rulechain.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. Cell Cells `json:"cell"`
  19. }
  20. type CreatChainReq struct {
  21. RecordId string `json:"record_id"`
  22. Name string `json:"name"`
  23. Cell Cells `json:"cells"`
  24. }
  25. type Cells []*Cell
  26. type Cell struct {
  27. Id string `json:"id"` // id
  28. Shape string `json:"shape"`
  29. Data CellData `json:"data"` // 数据
  30. Source Branch `json:"source"` // 上级节点
  31. Target Branch `json:"target"` // 下级节点
  32. }
  33. type CellData struct {
  34. Name string `json:"name"` // 名称
  35. Id string `json:"id"` // id
  36. Type string `json:"type"` // 节点类型
  37. Desc string `json:"desc"` // 备注
  38. ZIndex string `json:"ZIndex"` // 序号
  39. FuncBody string `json:"func_body"` // 代码
  40. Label string `json:"label"`
  41. Source string `json:"source"` // 源节点id
  42. Target string `json:"target"` // 目标节点id
  43. MesType []string `json:"mes_type"` // 消息类型
  44. Headers []*Headers `json:"headers"`
  45. Url string `json:"url"`
  46. Method string `json:"method"`
  47. Retry int `json:"retry"`
  48. TimeOut int `json:"time_out"`
  49. RetryWait int `json:"retry_wait"`
  50. }
  51. type NodeConfiguration struct {
  52. Url string `json:"url"`
  53. Method string `json:"method"`
  54. Headers map[string]interface{} `json:"headers"`
  55. Retry int `json:"retry"`
  56. TimeOut int `json:"time_out"`
  57. RetryWait int `json:"retry_wait"`
  58. }
  59. type Headers struct {
  60. Key string `json:"key"`
  61. Value string `json:"value"`
  62. }
  63. type Branch struct {
  64. Cell string `json:"cell"`
  65. }
  66. // Validate ``
  67. func (a *RuleChain) Validate() error {
  68. if a.Name == "" {
  69. return errors.New("规则链名称为空")
  70. }
  71. return nil
  72. }