uhf_reader.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package dao
  2. import (
  3. "time"
  4. "wails-app/internal/global"
  5. )
  6. // 连接类型
  7. const (
  8. ConnectTypeTCP = "tcp"
  9. ConnectTypeSerial = "serial"
  10. ConnectTypeMQTT = "mqtt"
  11. )
  12. type UHFReader struct {
  13. global.GVA_MODEL
  14. DeviceCode string `gorm:"size:50;not null;uniqueIndex" json:"device_code"`
  15. DeviceName string `gorm:"size:100;not null" json:"device_name"`
  16. DeviceType string `gorm:"size:100;not null" json:"device_type"`
  17. DeviceID string `gorm:"size:100;index" json:"device_id"` // 永久硬件身份,不能由管理员随意修改
  18. // ========== 连接方式配置 ==========
  19. ConnectType string `gorm:"size:20;not null;default:'tcp'" json:"connect_type"` // tcp / serial
  20. // TCP 配置
  21. IPAddress string `gorm:"size:50" json:"ip_address"`
  22. Port int `gorm:"default:0" json:"port"`
  23. // Serial(RS232) 配置
  24. COMPort string `gorm:"size:50" json:"com_port"` // COM3 /dev/ttyUSB0
  25. BaudRate int `gorm:"default:9600" json:"baud_rate"` // 波特率
  26. Status string `gorm:"size:20;default:'offline'" json:"status"`
  27. ProvisionStatus string `gorm:"size:20;default:'unprovisioned';index" json:"provision_status"`
  28. ProvisionMethod string `gorm:"size:20;default:'legacy'" json:"provision_method"`
  29. ProvisionError string `gorm:"size:500" json:"provision_error"`
  30. IdentityVerifiedAt *time.Time `json:"identity_verified_at"`
  31. ProvisionedAt *time.Time `json:"provisioned_at"`
  32. LastDiscoveredAt *time.Time `json:"last_discovered_at"`
  33. DiscoveredIP string `gorm:"size:50" json:"discovered_ip"`
  34. ConfigPort int `gorm:"default:0" json:"config_port"`
  35. DeviceModel string `gorm:"size:100" json:"device_model"`
  36. FirmwareVersion string `gorm:"size:100" json:"firmware_version"`
  37. DevicePublicKey string `gorm:"type:text" json:"device_public_key"`
  38. IsActive bool `gorm:"default:true" json:"is_active"`
  39. Description string `gorm:"size:200" json:"description"`
  40. ParkingLotID uint `json:"parking_lot_id"`
  41. ParkingLot ParkingLot `gorm:"foreignkey:ParkingLotID" json:"parking_lot"`
  42. LastOnlineTime *time.Time `json:"last_online_time" gorm:"comment:最后上线时间;default:null"`
  43. ChannelID uint `gorm:"comment:绑定通道ID" json:"channel_id"`
  44. Channel *Channel `gorm:"foreignKey:ChannelID;references:ID" json:"channel"`
  45. }
  46. func (UHFReader) TableName() string {
  47. return "uhf_reader"
  48. }