storage.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package model
  2. import "time"
  3. type StorageA struct {
  4. ID uint `json:"id" gorm:"primaryKey"` // unique key
  5. MountPath string `json:"mount_path" gorm:"unique" binding:"required"` // must be standardized
  6. Order int `json:"order"` // use to sort
  7. Driver string `json:"driver"` // driver used
  8. CacheExpiration int `json:"cache_expiration"` // cache expire time
  9. Status string `json:"status"`
  10. Addition string `json:"addition" gorm:"type:text"` // Additional information, defined in the corresponding driver
  11. Remark string `json:"remark"`
  12. Modified time.Time `json:"modified"`
  13. Disabled bool `json:"disabled"` // if disabled
  14. Sort
  15. Proxy
  16. }
  17. type Sort struct {
  18. OrderBy string `json:"order_by"`
  19. OrderDirection string `json:"order_direction"`
  20. ExtractFolder string `json:"extract_folder"`
  21. }
  22. type Proxy struct {
  23. WebProxy bool `json:"web_proxy"`
  24. WebdavPolicy string `json:"webdav_policy"`
  25. DownProxyUrl string `json:"down_proxy_url"`
  26. }
  27. func (s *StorageA) GetStorage() *StorageA {
  28. return s
  29. }
  30. func (s *StorageA) SetStorage(storage StorageA) {
  31. *s = storage
  32. }
  33. func (s *StorageA) SetStatus(status string) {
  34. s.Status = status
  35. }
  36. func (p Proxy) Webdav302() bool {
  37. return p.WebdavPolicy == "302_redirect"
  38. }
  39. func (p Proxy) WebdavProxy() bool {
  40. return p.WebdavPolicy == "use_proxy_url"
  41. }
  42. func (p Proxy) WebdavNative() bool {
  43. return !p.Webdav302() && !p.WebdavProxy()
  44. }