param.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package model
  2. const (
  3. _defaultWmPaddingX = 10
  4. _defaultWmPaddingY = 10
  5. _defaultWmScale = float64(1) / 24
  6. // delete status .please read document.
  7. // http://info.bilibili.co/pages/viewpage.action?pageId=8718262#bfs%E7%AE%A1%E7%90%86%E5%90%8E%E5%8F%B0%E7%9B%B8%E5%85%B3%E6%8E%A5%E5%8F%A3%E6%96%87%E6%A1%A3-db%E8%AE%BE%E8%AE%A1
  8. // PassStatus express pass status.
  9. PassStatus = 2
  10. // DeleteStatus .
  11. DeleteStatus = 3
  12. )
  13. // AddParam describe add api param
  14. type AddParam struct {
  15. Bucket string `json:"bucket" form:"bucket" validate:"required"`
  16. FileName string `json:"filename" form:"filename" validate:"required"`
  17. URL string `json:"url" form:"url"`
  18. Sex int `json:"sex" form:"sex"`
  19. Politics int `json:"politics" form:"politics"`
  20. }
  21. // ListParam describe list api param
  22. type ListParam struct {
  23. Bucket string `json:"bucket" form:"bucket" validate:"required"`
  24. State int `json:"state" form:"state" validate:"required,min=0"`
  25. PN int `json:"pn" form:"pn" validate:"min=1"`
  26. PS int `json:"ps" form:"ps" validate:"min=1"`
  27. }
  28. // MultiListParam describe list api param
  29. type MultiListParam struct {
  30. Bucket []string `json:"bucket" form:"bucket"`
  31. State int `json:"state" form:"state" validate:"min=0"`
  32. PN int `json:"pn" form:"pn" validate:"min=1" default:"1"`
  33. PS int `json:"ps" form:"ps" validate:"min=1" default:"50"`
  34. }
  35. // DeleteParam describe list api param
  36. type DeleteParam struct {
  37. Rid int `json:"rid" form:"rid" validate:"required"`
  38. Bucket string `json:"bucket"`
  39. FileName string `json:"filename"`
  40. AdminID int64 `json:"admin_id"`
  41. }
  42. // DeleteV2Param describe list api param
  43. type DeleteV2Param struct {
  44. Rid int `json:"rid" form:"rid" validate:"required"`
  45. Status int `json:"status" form:"status" validate:"required"`
  46. Bucket string `json:"bucket"`
  47. FileName string `json:"filename"`
  48. AdminID int64 `json:"admin_id"`
  49. }
  50. // DeleteRawParam describe list api param
  51. type DeleteRawParam struct {
  52. Bucket string `json:"bucket" form:"bucket" validate:"required"`
  53. FileName string `json:"filename" form:"filename" validate:"required"`
  54. }
  55. // AddBucketParam .
  56. type AddBucketParam struct {
  57. Name string `form:"name" json:"name" validate:"required"`
  58. Property int `form:"property" json:"property" validate:"min=0,max=3"`
  59. KeyID string `form:"key_id" json:"key_id" validate:"required"`
  60. KeySecret string `form:"key_secret" json:"key_secret" validate:"required"`
  61. PurgeCDN bool `form:"purge_cdn" json:"purge_cdn"`
  62. CacheControl int `form:"cache_control" json:"cache_control"`
  63. Domain string `form:"domain" json:"domain"`
  64. }
  65. // AddDirParam .
  66. type AddDirParam struct {
  67. BucketName string `form:"bucket_name" validate:"required"`
  68. DirName string `form:"dir_name" validate:"required"`
  69. Pic string `form:"pic"`
  70. Rate string `form:"rate"`
  71. }
  72. // ListBucketParam .
  73. type ListBucketParam struct {
  74. PN int `form:"pn" validate:"min=1"`
  75. PS int `form:"ps" validate:"min=1"`
  76. }
  77. // UploadParam .
  78. type UploadParam struct {
  79. Bucket string `form:"bucket" json:"bucket" validate:"required" `
  80. ContentType string `form:"content_type" json:"content_type"`
  81. Auth string `form:"auth" json:"-"`
  82. Dir string `form:"dir" json:"dir"`
  83. FileName string `form:"file_name" json:"file_name"`
  84. WmKey string `form:"wm_key" json:"wm_key"`
  85. WmText string `form:"wm_text" json:"wm_text"`
  86. WmPaddingX int `form:"wm_padding_x" json:"wm_padding_x"`
  87. WmPaddingY int `form:"wm_padding_y" json:"wm_padding_y"`
  88. WmScale float64 `form:"wm_scale" json:"wm_scale"`
  89. }
  90. // WMInit init UploadParam
  91. func (up *UploadParam) WMInit() {
  92. if up.WmKey != "" || up.WmText != "" {
  93. if up.WmPaddingX < 0 {
  94. up.WmPaddingX = _defaultWmPaddingX
  95. }
  96. if up.WmPaddingY < 0 {
  97. up.WmPaddingY = _defaultWmPaddingY
  98. }
  99. if up.WmScale <= 0 {
  100. up.WmScale = _defaultWmScale
  101. }
  102. }
  103. }
  104. // UploadResult .
  105. type UploadResult struct {
  106. Location string `json:"location"`
  107. Etag string `json:"etag"`
  108. }
  109. // MultiListResult .
  110. type MultiListResult struct {
  111. Bucket string `json:"bucket"`
  112. Imgs []*Record `json:"imgs"`
  113. }