playlist.go 2.4 KB

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