2015-12-22 04:07:15 -06:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Typed errors
|
|
|
|
var (
|
2020-11-05 06:07:06 -06:00
|
|
|
ErrPlaylistNotFound = errors.New("playlist not found")
|
|
|
|
ErrPlaylistWithSameNameExists = errors.New("a playlist with the same name already exists")
|
2015-12-22 04:07:15 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// Playlist model
|
|
|
|
type Playlist struct {
|
2016-01-08 10:32:55 -06:00
|
|
|
Id int64 `json:"id"`
|
2016-01-18 09:00:11 -06:00
|
|
|
Name string `json:"name"`
|
2016-01-12 06:56:47 -06:00
|
|
|
Interval string `json:"interval"`
|
2016-01-08 10:32:55 -06:00
|
|
|
OrgId int64 `json:"-"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PlaylistDTO struct {
|
|
|
|
Id int64 `json:"id"`
|
2016-01-18 09:00:11 -06:00
|
|
|
Name string `json:"name"`
|
2016-01-12 06:56:47 -06:00
|
|
|
Interval string `json:"interval"`
|
2016-01-08 10:32:55 -06:00
|
|
|
OrgId int64 `json:"-"`
|
|
|
|
Items []PlaylistItemDTO `json:"items"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PlaylistItemDTO struct {
|
|
|
|
Id int64 `json:"id"`
|
|
|
|
PlaylistId int64 `json:"playlistid"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Value string `json:"value"`
|
|
|
|
Order int `json:"order"`
|
2015-12-22 04:07:15 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type PlaylistDashboard struct {
|
|
|
|
Id int64 `json:"id"`
|
|
|
|
Slug string `json:"slug"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
}
|
|
|
|
|
2016-01-08 10:32:55 -06:00
|
|
|
type PlaylistItem struct {
|
|
|
|
Id int64
|
|
|
|
PlaylistId int64
|
|
|
|
Type string
|
|
|
|
Value string
|
|
|
|
Order int
|
|
|
|
Title string
|
|
|
|
}
|
|
|
|
|
2020-11-05 06:07:06 -06:00
|
|
|
func (p PlaylistDashboard) TableName() string {
|
2015-12-22 04:07:15 -06:00
|
|
|
return "dashboard"
|
|
|
|
}
|
|
|
|
|
|
|
|
type Playlists []*Playlist
|
|
|
|
type PlaylistDashboards []*PlaylistDashboard
|
|
|
|
|
|
|
|
//
|
|
|
|
// COMMANDS
|
|
|
|
//
|
|
|
|
|
2016-01-18 09:00:11 -06:00
|
|
|
type UpdatePlaylistCommand struct {
|
|
|
|
OrgId int64 `json:"-"`
|
2018-07-17 09:45:39 -05:00
|
|
|
Id int64 `json:"id"`
|
2016-01-18 09:00:11 -06:00
|
|
|
Name string `json:"name" binding:"Required"`
|
|
|
|
Interval string `json:"interval"`
|
|
|
|
Items []PlaylistItemDTO `json:"items"`
|
2015-12-22 04:07:15 -06:00
|
|
|
|
2016-01-08 10:32:55 -06:00
|
|
|
Result *PlaylistDTO
|
2015-12-22 04:07:15 -06:00
|
|
|
}
|
|
|
|
|
2016-01-18 09:00:11 -06:00
|
|
|
type CreatePlaylistCommand struct {
|
|
|
|
Name string `json:"name" binding:"Required"`
|
|
|
|
Interval string `json:"interval"`
|
|
|
|
Items []PlaylistItemDTO `json:"items"`
|
2015-12-22 04:07:15 -06:00
|
|
|
|
2016-01-18 09:00:11 -06:00
|
|
|
OrgId int64 `json:"-"`
|
2015-12-22 04:07:15 -06:00
|
|
|
Result *Playlist
|
|
|
|
}
|
|
|
|
|
2016-01-18 09:00:11 -06:00
|
|
|
type DeletePlaylistCommand struct {
|
|
|
|
Id int64
|
|
|
|
OrgId int64
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// QUERIES
|
|
|
|
//
|
|
|
|
|
|
|
|
type GetPlaylistsQuery struct {
|
|
|
|
Name string
|
|
|
|
Limit int
|
|
|
|
OrgId int64
|
|
|
|
|
|
|
|
Result Playlists
|
|
|
|
}
|
|
|
|
|
2015-12-22 04:07:15 -06:00
|
|
|
type GetPlaylistByIdQuery struct {
|
|
|
|
Id int64
|
|
|
|
Result *Playlist
|
|
|
|
}
|
|
|
|
|
2016-01-08 10:32:55 -06:00
|
|
|
type GetPlaylistItemsByIdQuery struct {
|
|
|
|
PlaylistId int64
|
|
|
|
Result *[]PlaylistItem
|
|
|
|
}
|