playlist.go 2.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
package models

import (
	"errors"
)

// Typed errors
var (
	ErrPlaylistNotFound           = errors.New("Playlist not found")
	ErrPlaylistWithSameNameExists = errors.New("A playlist with the same name already exists")
)

// Playlist model
type Playlist struct {
15
	Id       int64  `json:"id"`
16
	Name     string `json:"name"`
17
	Interval string `json:"interval"`
18 19 20 21 22
	OrgId    int64  `json:"-"`
}

type PlaylistDTO struct {
	Id       int64             `json:"id"`
23
	Name     string            `json:"name"`
24
	Interval string            `json:"interval"`
25 26 27 28 29 30 31 32 33 34 35
	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"`
36 37 38 39 40 41 42 43
}

type PlaylistDashboard struct {
	Id    int64  `json:"id"`
	Slug  string `json:"slug"`
	Title string `json:"title"`
}

44 45 46 47 48 49 50 51 52
type PlaylistItem struct {
	Id         int64
	PlaylistId int64
	Type       string
	Value      string
	Order      int
	Title      string
}

53 54 55 56 57 58 59 60 61 62 63
func (this PlaylistDashboard) TableName() string {
	return "dashboard"
}

type Playlists []*Playlist
type PlaylistDashboards []*PlaylistDashboard

//
// COMMANDS
//

64 65
type UpdatePlaylistCommand struct {
	OrgId    int64             `json:"-"`
66
	Id       int64             `json:"id"`
67 68 69
	Name     string            `json:"name" binding:"Required"`
	Interval string            `json:"interval"`
	Items    []PlaylistItemDTO `json:"items"`
70

71
	Result *PlaylistDTO
72 73
}

74 75 76 77
type CreatePlaylistCommand struct {
	Name     string            `json:"name" binding:"Required"`
	Interval string            `json:"interval"`
	Items    []PlaylistItemDTO `json:"items"`
78

79
	OrgId  int64 `json:"-"`
80 81 82
	Result *Playlist
}

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
type DeletePlaylistCommand struct {
	Id    int64
	OrgId int64
}

//
// QUERIES
//

type GetPlaylistsQuery struct {
	Name  string
	Limit int
	OrgId int64

	Result Playlists
}

100 101 102 103 104
type GetPlaylistByIdQuery struct {
	Id     int64
	Result *Playlist
}

105 106 107 108
type GetPlaylistItemsByIdQuery struct {
	PlaylistId int64
	Result     *[]PlaylistItem
}