playlist.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. // DTOS
  52. //
  53. type PlaylistDashboardDto struct {
  54. Id int64 `json:"id"`
  55. Slug string `json:"slug"`
  56. Title string `json:"title"`
  57. Uri string `json:"uri"`
  58. }
  59. //
  60. // COMMANDS
  61. //
  62. type UpdatePlaylistCommand struct {
  63. OrgId int64 `json:"-"`
  64. Id int64 `json:"id" binding:"Required"`
  65. Name string `json:"name" binding:"Required"`
  66. Type string `json:"type"`
  67. Interval string `json:"interval"`
  68. Data []int64 `json:"data"`
  69. Items []PlaylistItemDTO `json:"items"`
  70. Result *PlaylistDTO
  71. }
  72. type CreatePlaylistCommand struct {
  73. Name string `json:"name" binding:"Required"`
  74. Type string `json:"type"`
  75. Interval string `json:"interval"`
  76. Data []int64 `json:"data"`
  77. Items []PlaylistItemDTO `json:"items"`
  78. OrgId int64 `json:"-"`
  79. Result *Playlist
  80. }
  81. type DeletePlaylistCommand struct {
  82. Id int64
  83. OrgId int64
  84. }
  85. //
  86. // QUERIES
  87. //
  88. type GetPlaylistsQuery struct {
  89. Name string
  90. Limit int
  91. OrgId int64
  92. Result Playlists
  93. }
  94. type GetPlaylistByIdQuery struct {
  95. Id int64
  96. Result *Playlist
  97. }
  98. type GetPlaylistItemsByIdQuery struct {
  99. PlaylistId int64
  100. Result *[]PlaylistItem
  101. }
  102. type GetPlaylistDashboardsQuery struct {
  103. DashboardIds []int64
  104. Result *PlaylistDashboards
  105. }