object.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package model
  2. import (
  3. "time"
  4. )
  5. type ObjWrapName struct {
  6. Name string
  7. Obj
  8. }
  9. func (o *ObjWrapName) Unwrap() Obj {
  10. return o.Obj
  11. }
  12. func (o *ObjWrapName) GetName() string {
  13. if o.Name == "" {
  14. o.Name = o.Obj.GetName()
  15. }
  16. return o.Name
  17. }
  18. type Object struct {
  19. ID string
  20. Path string
  21. Name string
  22. Size int64
  23. Modified time.Time
  24. IsFolder bool
  25. }
  26. func (o *Object) GetName() string {
  27. return o.Name
  28. }
  29. func (o *Object) GetSize() int64 {
  30. return o.Size
  31. }
  32. func (o *Object) ModTime() time.Time {
  33. return o.Modified
  34. }
  35. func (o *Object) IsDir() bool {
  36. return o.IsFolder
  37. }
  38. func (o *Object) GetID() string {
  39. return o.ID
  40. }
  41. func (o *Object) GetPath() string {
  42. return o.Path
  43. }
  44. func (o *Object) SetPath(id string) {
  45. o.Path = id
  46. }
  47. type Thumbnail struct {
  48. Thumbnail string
  49. }
  50. type Url struct {
  51. Url string
  52. }
  53. func (w Url) URL() string {
  54. return w.Url
  55. }
  56. func (t Thumbnail) Thumb() string {
  57. return t.Thumbnail
  58. }
  59. type ObjThumb struct {
  60. Object
  61. Thumbnail
  62. }
  63. type ObjectURL struct {
  64. Object
  65. Url
  66. }
  67. type ObjThumbURL struct {
  68. Object
  69. Thumbnail
  70. Url
  71. }