playlist.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. Interval string `json:"interval"`
  67. Items []PlaylistItemDTO `json:"items"`
  68. Result *PlaylistDTO
  69. }
  70. type CreatePlaylistCommand struct {
  71. Name string `json:"name" binding:"Required"`
  72. Interval string `json:"interval"`
  73. Items []PlaylistItemDTO `json:"items"`
  74. OrgId int64 `json:"-"`
  75. Result *Playlist
  76. }
  77. type DeletePlaylistCommand struct {
  78. Id int64
  79. OrgId int64
  80. }
  81. //
  82. // QUERIES
  83. //
  84. type GetPlaylistsQuery struct {
  85. Name string
  86. Limit int
  87. OrgId int64
  88. Result Playlists
  89. }
  90. type GetPlaylistByIdQuery struct {
  91. Id int64
  92. Result *Playlist
  93. }
  94. type GetPlaylistItemsByIdQuery struct {
  95. PlaylistId int64
  96. Result *[]PlaylistItem
  97. }