playlist.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 []int64 `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. // DTOS
  31. //
  32. type PlaylistDashboardDto struct {
  33. Id int64 `json:"id"`
  34. Slug string `json:"slug"`
  35. Title string `json:"title"`
  36. Uri string `json:"uri"`
  37. }
  38. //
  39. // COMMANDS
  40. //
  41. type PlaylistQuery struct {
  42. Title string
  43. Limit int
  44. OrgId int64
  45. Result Playlists
  46. }
  47. type UpdatePlaylistQuery struct {
  48. Id int64
  49. Title string
  50. Type string
  51. Timespan string
  52. Data []int64
  53. Result *Playlist
  54. }
  55. type CreatePlaylistQuery struct {
  56. Title string
  57. Type string
  58. Timespan string
  59. Data []int64
  60. OrgId int64
  61. Result *Playlist
  62. }
  63. type GetPlaylistByIdQuery struct {
  64. Id int64
  65. Result *Playlist
  66. }
  67. type GetPlaylistDashboardsQuery struct {
  68. Id int64
  69. Result *PlaylistDashboards
  70. }
  71. type DeletePlaylistQuery struct {
  72. Id int64
  73. }