ota.go 855 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package models
  2. import (
  3. "errors"
  4. "github.com/jinzhu/gorm"
  5. )
  6. type Ota struct {
  7. gorm.Model
  8. RecordId string `gorm:"column:record_id;size:32;index"`
  9. Name string `gorm:"column:name;size:30"`
  10. Url string `gorm:"column:url;size:200"`
  11. Version string `gorm:"column:version;size:20"`
  12. Size int `gorm:"column:size;"`
  13. VendorId string `gorm:"column:vendor_id;size:32;"`
  14. }
  15. // Validate 验证
  16. func (a *Ota) Validate() error {
  17. if a.Url == "" {
  18. return errors.New("非法参数:[url]")
  19. }
  20. return nil
  21. }
  22. type OtaUpgradeParams struct {
  23. VendorId string `json:"vendor_id"`
  24. FileId string `json:"file_id"`
  25. ProductId string `json:"product_id"`
  26. DeviceIDs []string `json:"device_id"`
  27. }
  28. // Validate 验证
  29. func (a *OtaUpgradeParams) Validate() error {
  30. if a.FileId == "" {
  31. return errors.New("非法参数:[file_id]")
  32. }
  33. return nil
  34. }