bucket.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package model
  2. import (
  3. xtime "go-common/library/time"
  4. )
  5. const (
  6. // PrivateReadBit 私有读位
  7. PrivateReadBit = 0
  8. // PrivateWriteBit 私有写位
  9. PrivateWriteBit = 1
  10. //status
  11. // Public = 0
  12. Public = int(0)
  13. // PrivateRead = 1
  14. PrivateRead = int(1 << PrivateReadBit)
  15. // PrivateWrite = 2
  16. PrivateWrite = int(1 << PrivateWriteBit)
  17. // PrivateReadWrite = 3
  18. PrivateReadWrite = int(PrivateRead | PrivateWrite)
  19. )
  20. // Bucket bucekt table orm
  21. type Bucket struct {
  22. ID int `json:"id" gorm:"column:id"`
  23. BucketName string `json:"bucket_name" gorm:"column:bucket_name"`
  24. Property int `json:"property" gorm:"column:property"`
  25. KeyID string `json:"key_id" gorm:"column:key_id"`
  26. KeySecret string `json:"key_secret" gorm:"column:key_secret"`
  27. PurgeCDN bool `json:"purge_cdn" gorm:"column:purge_cdn"`
  28. CacheControl int `json:"cache_control" gorm:"column:cache_control"`
  29. Domain string `json:"domain" gorm:"column:domain"`
  30. CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
  31. MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
  32. DirLimit []*DirLimit `json:"dir_limit" gorm:"-"`
  33. }
  34. // TableName bucket
  35. func (b Bucket) TableName() string {
  36. return "bucket"
  37. }
  38. // Page common page response
  39. type Page struct {
  40. PS int `json:"ps"`
  41. PN int `json:"pn"`
  42. Total int `json:"total"`
  43. }
  44. // BucketListPage bucket/list result
  45. type BucketListPage struct {
  46. Items []*Bucket `json:"items"`
  47. Page *Page `json:"page"`
  48. }