flow.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package net
  2. import (
  3. "time"
  4. )
  5. const (
  6. // TableFlow .
  7. TableFlow = "net_flow"
  8. )
  9. // Flow 节点
  10. type Flow struct {
  11. ID int64 `gorm:"primary_key" json:"id"`
  12. NetID int64 `gorm:"column:net_id" json:"net_id"`
  13. Name string `gorm:"column:name" json:"name"`
  14. ChName string `gorm:"column:ch_name" json:"ch_name"`
  15. Description string `gorm:"column:description" json:"description"`
  16. UID int64 `gorm:"column:uid" json:"uid"`
  17. DisableTime time.Time `gorm:"column:disable_time" json:"disable_time"`
  18. Ctime time.Time `gorm:"column:ctime" json:"ctime"`
  19. Mtime time.Time `gorm:"column:mtime" json:"mtime"`
  20. }
  21. // TableName .
  22. func (f *Flow) TableName() string {
  23. return TableFlow
  24. }
  25. // IsAvailable .
  26. func (f *Flow) IsAvailable() bool {
  27. return f.DisableTime.IsZero()
  28. }
  29. // FlowArr .
  30. type FlowArr []*Flow
  31. func (a FlowArr) Len() int {
  32. return len(a)
  33. }
  34. func (a FlowArr) Less(i, j int) bool {
  35. return a[i].ID < a[j].ID
  36. }
  37. func (a FlowArr) Swap(i, j int) {
  38. a[i], a[j] = a[j], a[i]
  39. }