direction.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package net
  2. import (
  3. "time"
  4. )
  5. const (
  6. // TableDirection .
  7. TableDirection = "net_direction"
  8. //DirInput 从flow指向transition
  9. DirInput = int8(1)
  10. //DirOutput 从transition指向flow
  11. DirOutput = int8(2)
  12. //DirOrderSequence 下游顺序执行
  13. DirOrderSequence = int8(0)
  14. //DirOrderOrSplit 下游根据条件拆分,各分支若为transition,可允许操作个数>=1
  15. DirOrderOrSplit = int8(1)
  16. //DirOrderOrResultSplit 下游transition操作拆分,每个transition只有一个可允许操作,enable均默认为true,但只能操作一个
  17. //先不做, 如果做了,在详情页提交后,怎么知道提交的是哪个transition(有多个)呢?
  18. DirOrderOrResultSplit = int8(2)
  19. //todo --- 其他顺序 v2
  20. )
  21. // DirDirectionDesc .
  22. var DirDirectionDesc = map[int8]string{
  23. DirInput: "从节点指向变化",
  24. DirOutput: "从变化指向节点",
  25. }
  26. // DirOrderDesc 有向线下游顺序描述
  27. var DirOrderDesc = map[int8]string{
  28. DirOrderSequence: "直序",
  29. }
  30. // Direction 有向线,连接flow和transition
  31. type Direction struct {
  32. ID int64 `gorm:"primary_key" json:"id" form:"id" validate:"omitempty,gt=0"`
  33. NetID int64 `gorm:"column:net_id" json:"net_id" form:"net_id" validate:"omitempty,gt=0"`
  34. FlowID int64 `gorm:"column:flow_id" json:"flow_id" form:"flow_id" validate:"required,gt=0"`
  35. TransitionID int64 `gorm:"column:transition_id" json:"transition_id" form:"transition_id" validate:"required,gt=0"`
  36. Direction int8 `gorm:"column:direction" json:"direction" form:"direction" validate:"required,min=1,max=2"`
  37. Order int8 `gorm:"column:order" json:"order" form:"order" validate:"omitempty,min=0,max=2"`
  38. Guard string `gorm:"column:guard" json:"guard"`
  39. Output string `gorm:"column:output" json:"output"`
  40. UID int64 `gorm:"column:uid" json:"uid"`
  41. DisableTime time.Time `gorm:"column:disable_time" json:"disable_time"`
  42. Ctime time.Time `gorm:"column:ctime" json:"ctime"`
  43. Mtime time.Time `gorm:"column:mtime" json:"mtime"`
  44. }
  45. // TableName .
  46. func (d *Direction) TableName() string {
  47. return TableDirection
  48. }
  49. // IsAvailable .
  50. func (d *Direction) IsAvailable() bool {
  51. return d.DisableTime.IsZero()
  52. }