device.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package models
  2. import (
  3. "time"
  4. )
  5. // BoundDevice represents a physical Spark ("微光") recording device bound to a user
  6. type BoundDevice struct {
  7. ID string `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
  8. UserID string `gorm:"type:uuid;not null;index;uniqueIndex:idx_device_user_peripheral" json:"userId"`
  9. Name string `gorm:"size:100;not null" json:"name"`
  10. PeripheralUUID string `gorm:"size:100;uniqueIndex:idx_device_user_peripheral" json:"peripheralUUID"`
  11. HardwareMAC string `gorm:"size:100" json:"hardwareMAC"`
  12. BatteryLevel int `gorm:"default:100" json:"batteryLevel"`
  13. FirmwareVersion string `gorm:"size:50;default:'v1.2.0'" json:"firmwareVersion"`
  14. FreeStorageMB int `gorm:"default:12000" json:"freeStorageMB"`
  15. TotalStorageMB int `gorm:"default:16000" json:"totalStorageMB"`
  16. IsConnected bool `gorm:"default:false" json:"isConnected"`
  17. BoundAt time.Time `gorm:"autoCreateTime" json:"boundAt"`
  18. UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updatedAt"`
  19. }
  20. type BindDeviceRequest struct {
  21. Name string `json:"name" binding:"required"`
  22. PeripheralUUID string `json:"peripheralUUID"`
  23. HardwareMAC string `json:"hardwareMAC"`
  24. FirmwareVersion string `json:"firmwareVersion"`
  25. BatteryLevel *int `json:"batteryLevel,omitempty"`
  26. FreeStorageMB *int `json:"freeStorageMB,omitempty"`
  27. TotalStorageMB *int `json:"totalStorageMB,omitempty"`
  28. }
  29. type UpdateDeviceRequest struct {
  30. Name *string `json:"name,omitempty"`
  31. BatteryLevel *int `json:"batteryLevel,omitempty"`
  32. IsConnected *bool `json:"isConnected,omitempty"`
  33. FirmwareVersion *string `json:"firmwareVersion,omitempty"`
  34. FreeStorageMB *int `json:"freeStorageMB,omitempty"`
  35. TotalStorageMB *int `json:"totalStorageMB,omitempty"`
  36. }