playlist.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. Title string `json:"title"`
  14. Type string `json:"type"`
  15. Timespan string `json:"timespan"`
  16. Data []int `json:"data"`
  17. OrgId int64 `json:"-"`
  18. }
  19. type PlaylistDashboard struct {
  20. Id int64 `json:"id"`
  21. Slug string `json:"slug"`
  22. Title string `json:"title"`
  23. }
  24. func (this PlaylistDashboard) TableName() string {
  25. return "dashboard"
  26. }
  27. type Playlists []*Playlist
  28. type PlaylistDashboards []*PlaylistDashboard
  29. //
  30. // COMMANDS
  31. //
  32. type PlaylistQuery struct {
  33. Title string
  34. Limit int
  35. OrgId int64
  36. Result Playlists
  37. }
  38. type UpdatePlaylistQuery struct {
  39. Id int64
  40. Title string
  41. Type string
  42. Timespan string
  43. Data []int
  44. Result *Playlist
  45. }
  46. type CreatePlaylistQuery struct {
  47. Title string
  48. Type string
  49. Timespan string
  50. Data []int
  51. OrgId int64
  52. Result *Playlist
  53. }
  54. type GetPlaylistByIdQuery struct {
  55. Id int64
  56. Result *Playlist
  57. }
  58. type GetPlaylistDashboardsQuery struct {
  59. Id int64
  60. Result *PlaylistDashboards
  61. }
  62. type DeletePlaylistQuery struct {
  63. Id int64
  64. }