ota.go 994 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. ProductId string `gorm:"column:product_id;size:32;index;"`
  14. ProductName string `gorm:"column:product_name;size:50;"`
  15. VendorId string `gorm:"column:vendor_id;size:32;"`
  16. }
  17. // Validate 验证
  18. func (a *Ota) Validate() error {
  19. if a.Url == "" {
  20. return errors.New("非法参数:[url]")
  21. }
  22. return nil
  23. }
  24. type OtaUpgradeParams struct {
  25. VendorId string `json:"vendor_id"`
  26. FileId string `json:"file_id"`
  27. ProductId string `json:"product_id"`
  28. DeviceIDs []string `json:"device_ids"`
  29. }
  30. // Validate 验证
  31. func (a *OtaUpgradeParams) Validate() error {
  32. if a.FileId == "" {
  33. return errors.New("非法参数:[file_id]")
  34. }
  35. return nil
  36. }