playlist.go 2.27 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
func (this PlaylistDashboard) TableName() string {
	return "dashboard"
}

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

//
61 62 63 64 65 66 67 68 69 70 71
// DTOS
//

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

//
72 73 74
// COMMANDS
//

75 76 77 78 79 80
type UpdatePlaylistCommand struct {
	OrgId    int64             `json:"-"`
	Id       int64             `json:"id" binding:"Required"`
	Name     string            `json:"name" binding:"Required"`
	Interval string            `json:"interval"`
	Items    []PlaylistItemDTO `json:"items"`
81

82
	Result *PlaylistDTO
83 84
}

85 86 87 88
type CreatePlaylistCommand struct {
	Name     string            `json:"name" binding:"Required"`
	Interval string            `json:"interval"`
	Items    []PlaylistItemDTO `json:"items"`
89

90
	OrgId  int64 `json:"-"`
91 92 93
	Result *Playlist
}

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
type DeletePlaylistCommand struct {
	Id    int64
	OrgId int64
}

//
// QUERIES
//

type GetPlaylistsQuery struct {
	Name  string
	Limit int
	OrgId int64

	Result Playlists
}

111 112 113 114 115
type GetPlaylistByIdQuery struct {
	Id     int64
	Result *Playlist
}

116 117 118 119
type GetPlaylistItemsByIdQuery struct {
	PlaylistId int64
	Result     *[]PlaylistItem
}