playlist.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package models
  2. import (
  3. "errors"
  4. )
  5. // Typed errors
  6. var (
  7. ErrPlaylistNotFound = errors.New("Playlist not found")
  8. ErrPlaylistWithSameNameExists = errors.New("A playlist with the same name already exists")
  9. )
  10. // Playlist model
  11. type Playlist struct {
  12. Id int64 `json:"id"`
  13. Name string `json:"name"`
  14. Interval string `json:"interval"`
  15. OrgId int64 `json:"-"`
  16. }
  17. type PlaylistDTO struct {
  18. Id int64 `json:"id"`
  19. Name string `json:"name"`
  20. Interval string `json:"interval"`
  21. OrgId int64 `json:"-"`
  22. Items []PlaylistItemDTO `json:"items"`
  23. }
  24. type PlaylistItemDTO struct {
  25. Id int64 `json:"id"`
  26. PlaylistId int64 `json:"playlistid"`
  27. Type string `json:"type"`
  28. Title string `json:"title"`
  29. Value string `json:"value"`
  30. Order int `json:"order"`
  31. }
  32. type PlaylistDashboard struct {
  33. Id int64 `json:"id"`
  34. Slug string `json:"slug"`
  35. Title string `json:"title"`
  36. }
  37. type PlaylistItem struct {
  38. Id int64
  39. PlaylistId int64
  40. Type string
  41. Value string
  42. Order int
  43. Title string
  44. }
  45. func (this PlaylistDashboard) TableName() string {
  46. return "dashboard"
  47. }
  48. type Playlists []*Playlist
  49. type PlaylistDashboards []*PlaylistDashboard
  50. //
  51. // COMMANDS
  52. //
  53. type UpdatePlaylistCommand struct {
  54. OrgId int64 `json:"-"`
  55. Id int64 `json:"id"`
  56. Name string `json:"name" binding:"Required"`
  57. Interval string `json:"interval"`
  58. Items []PlaylistItemDTO `json:"items"`
  59. Result *PlaylistDTO
  60. }
  61. type CreatePlaylistCommand struct {
  62. Name string `json:"name" binding:"Required"`
  63. Interval string `json:"interval"`
  64. Items []PlaylistItemDTO `json:"items"`
  65. OrgId int64 `json:"-"`
  66. Result *Playlist
  67. }
  68. type DeletePlaylistCommand struct {
  69. Id int64
  70. OrgId int64
  71. }
  72. //
  73. // QUERIES
  74. //
  75. type GetPlaylistsQuery struct {
  76. Name string
  77. Limit int
  78. OrgId int64
  79. Result Playlists
  80. }
  81. type GetPlaylistByIdQuery struct {
  82. Id int64
  83. Result *Playlist
  84. }
  85. type GetPlaylistItemsByIdQuery struct {
  86. PlaylistId int64
  87. Result *[]PlaylistItem
  88. }