transition.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package net
  2. import (
  3. "time"
  4. )
  5. //..
  6. const (
  7. TableTransition = "net_transition"
  8. //TriggerManual 人工触发,一旦enable,执行由人审核提交
  9. TriggerManual = int8(1)
  10. //TriggerAuto 自动触发,一旦enable就可执行
  11. TriggerAuto = int8(2)
  12. //TriggerMsg 消息触发,一旦enable,执行为接收到指定消息
  13. TriggerMsg = int8(3)
  14. )
  15. //TriggerDesc 变迁触发类型描述
  16. var TriggerDesc = map[int8]string{
  17. TriggerAuto: "直序",
  18. TriggerManual: "人工",
  19. TriggerMsg: "消息",
  20. }
  21. //Transition 变迁
  22. type Transition struct {
  23. ID int64 `gorm:"primary_key" json:"id" form:"id" validate:"omitempty,gt=0"`
  24. NetID int64 `gorm:"column:net_id" json:"net_id" form:"net_id" validate:"omitempty,gt=0"`
  25. Trigger int8 `gorm:"column:trigger" json:"trigger" default:"1" form:"trigger"`
  26. Limit int64 `gorm:"column:limit" json:"limit" form:"limit"`
  27. Name string `gorm:"column:name" json:"name" form:"name" validate:"required,max=32"`
  28. ChName string `gorm:"column:ch_name" json:"ch_name" form:"ch_name" validate:"required,max=16"`
  29. Description string `gorm:"column:description" json:"description" form:"description" validate:"max=60"`
  30. UID int64 `gorm:"column:uid" json:"uid"`
  31. DisableTime time.Time `gorm:"column:disable_time" json:"disable_time"`
  32. Ctime time.Time `gorm:"column:ctime" json:"ctime"`
  33. Mtime time.Time `gorm:"column:mtime" json:"mtime"`
  34. }
  35. //TableName .
  36. func (t *Transition) TableName() string {
  37. return TableTransition
  38. }
  39. //IsAvailable .
  40. func (t *Transition) IsAvailable() bool {
  41. return t.DisableTime.IsZero()
  42. }