dto

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package dto forms the bridge between the api data and the internal models

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Directory

type Directory struct {
	ID        int         `json:"id"`
	Name      string      `json:"name" validate:"required"`
	Children  []Directory `json:"children,omitzero"`
	Playlists []Playlist  `json:"playlists" validate:"required"`
}

func DirectoryDTO

func DirectoryDTO(d *model.Directory, models []*model.Directory) Directory

func (Directory) ToModel

func (d Directory) ToModel(userID, parentID int) *model.Directory

type Generator added in v0.2.0

type Generator struct {
	ID              int             `json:"id"`
	Name            string          `json:"name" validate:"required"`
	Description     string          `json:"description,omitzero"`
	PlaylistID      int             `json:"playlist_id,omitzero"`
	IntervalDays    int             `json:"interval_days"`
	SpotifyOutdated bool            `json:"spotify_outdated"`
	Params          GeneratorParams `json:"params" validate:"required"`
	Tracks          []Track         `json:"tracks"`
	UpdatedAt       time.Time       `json:"updated_at"`
}

func GeneratorDTO added in v0.2.0

func GeneratorDTO(gen *model.Generator) Generator

type GeneratorParams added in v0.2.0

type GeneratorParams struct {
	TrackAmount         int   `json:"track_amount" validate:"min=0"`
	ExcludedPlaylistIDs []int `json:"excluded_playlist_ids,omitzero"`
	ExcludedTrackIDs    []int `json:"excluded_track_ids,omitzero"`

	Preset model.GeneratorPreset `json:"preset" validate:"required"`

	ParamsTop    *GeneratorPresetTopParams    `json:"params_top,omitzero"`
	ParamsOldTop *GeneratorPresetOldTopParams `json:"params_old_top,omitzero"`
}

func (GeneratorParams) ToModel added in v0.2.0

type GeneratorPresetOldTopParams added in v0.2.0

type GeneratorPresetOldTopParams struct {
	PeakWindow   GeneratorWindow `json:"peak_window"`
	RecentWindow GeneratorWindow `json:"recent_window"`
}

func (GeneratorPresetOldTopParams) ToModel added in v0.2.0

type GeneratorPresetTopParams added in v0.2.0

type GeneratorPresetTopParams struct {
	Window GeneratorWindow `json:"window"`
}

func (GeneratorPresetTopParams) ToModel added in v0.2.0

type GeneratorSave added in v0.2.0

type GeneratorSave struct {
	ID             int             `json:"id"`
	Name           string          `json:"name" validate:"required"`
	Description    string          `json:"description"`
	CreatePlaylist bool            `json:"create_playlist"`
	IntervalDays   int             `json:"interval_days" validate:"min=0"`
	Params         GeneratorParams `json:"params" validate:"required"`
}

func (GeneratorSave) ToModel added in v0.2.0

func (g GeneratorSave) ToModel(userID int) *model.Generator

type GeneratorWindow added in v0.2.0

type GeneratorWindow struct {
	Start             time.Time `json:"start"`
	End               time.Time `json:"end"`
	MinPlays          int       `json:"min_plays" validate:"min=0"`
	BurstIntervalDays int       `json:"burst_interval_days"`
	Dynamic           bool      `json:"dynamic"`
}

func (GeneratorWindow) ToModel added in v0.2.0

func (g GeneratorWindow) ToModel() *model.GeneratorWindow

type History

type History struct {
	Track

	HistoryID int       `json:"history_id"`
	PlayedAt  time.Time `json:"played_at"`
	PlayCount int       `json:"play_count,omitzero"`
}

func HistoryDTO

func HistoryDTO(t *model.Track, h *model.History) History

type HistoryFilter

type HistoryFilter struct {
	UserID  int
	Skipped *bool
	Start   time.Time
	End     time.Time
	Limit   int
	Offset  int
}

func (HistoryFilter) ToModel

func (h HistoryFilter) ToModel() *model.HistoryFilter
type Link struct {
	ID                int `json:"id"`
	SourceDirectoryID int `json:"source_directory_id,omitzero"`
	SourcePlaylistID  int `json:"source_playlist_id,omitzero"`
	TargetDirectoryID int `json:"target_directory_id,omitzero"`
	TargetPlaylistID  int `json:"target_playlist_id,omitzero"`
}

func LinkDTO

func LinkDTO(l *model.Link) Link

func (*Link) ToModel

func (l *Link) ToModel() *model.Link

type Playlist

type Playlist struct {
	ID            int    `json:"id" validate:"required"`
	SpotifyID     string `json:"spotify_id"`
	Owner         User   `json:"owner,omitzero"`
	Name          string `json:"name"`
	Description   string `json:"description,omitzero"`
	Public        *bool  `json:"public,omitzero"`
	TrackAmount   int    `json:"track_amount"`
	Collaborative *bool  `json:"collaborative,omitzero"`
	HasCover      bool   `json:"has_cover"`
}

func PlaylistDTO

func PlaylistDTO(playlist *model.Playlist, user *model.User) Playlist

func (Playlist) ToModel

func (p Playlist) ToModel() *model.Playlist

type PlaylistDuplicate

type PlaylistDuplicate struct {
	Playlist
	Duplicates []TrackDuplicate `json:"duplicates"`
}

func PlaylistDuplicateDTO

func PlaylistDuplicateDTO(playlist *model.Playlist, user *model.User, duplicates []model.Track) PlaylistDuplicate

type PlaylistUnplayable

type PlaylistUnplayable struct {
	Playlist
	Unplayables []Track `json:"unplayables"`
}

func PlaylistUnplayableDTO

func PlaylistUnplayableDTO(playlist *model.Playlist, user *model.User, unplayables []model.Track) PlaylistUnplayable

type Task

type Task struct {
	TaskUID     string           `json:"uid"`
	Name        string           `json:"name"`
	Status      task.Status      `json:"status"`
	NextRun     time.Time        `json:"next_run,omitzero"`
	LastStatus  model.TaskResult `json:"last_status,omitempty"`
	LastRun     *time.Time       `json:"last_run,omitzero"`
	LastMessage string           `json:"last_message,omitempty"`
	LastError   string           `json:"last_error,omitempty"`
	Interval    *time.Duration   `json:"interval,omitzero"`
	Recurring   bool             `json:"recurring"`
}

func TaskDTO

func TaskDTO(task task.Stat) Task

type TaskFilter

type TaskFilter struct {
	UserID    int
	TaskUID   string
	Result    *model.TaskResult
	Recurring *bool
	Limit     int
	Offset    int
}

func (*TaskFilter) ToModel

func (t *TaskFilter) ToModel() *model.TaskFilter

type TaskHistory

type TaskHistory struct {
	ID       int              `json:"id"`
	Name     string           `json:"name"`
	Result   model.TaskResult `json:"result"`
	RunAt    time.Time        `json:"run_at"`
	Message  string           `json:"message"`
	Error    string           `json:"error,omitempty"`
	Duration time.Duration    `json:"duration"`
}

func TaskHistoryDTO

func TaskHistoryDTO(task *model.Task) TaskHistory

type Track

type Track struct {
	ID        int    `json:"id"`
	SpotifyID string `json:"spotify_id"`
	Name      string `json:"name"`
}

func TrackDTO

func TrackDTO(t *model.Track) Track

type TrackAdded

type TrackAdded struct {
	Track

	Playlist  Playlist  `json:"playlist"`
	CreatedAt time.Time `json:"created_at"`
}

func TrackAddedDTO

func TrackAddedDTO(t *model.Track) TrackAdded

type TrackDeleted

type TrackDeleted struct {
	Track

	Playlist  Playlist  `json:"playlist"`
	DeletedAt time.Time `json:"deleted_at"`
}

func TrackDeletedDTO

func TrackDeletedDTO(t *model.Track) TrackDeleted

type TrackDuplicate

type TrackDuplicate struct {
	Track

	Amount int `json:"amount"`
}

func TrackDuplicateDTO

func TrackDuplicateDTO(t *model.Track, amount int) TrackDuplicate

type TrackFilter

type TrackFilter struct {
	UserID     int
	PlaylistID int
	Limit      int
	Offset     int
}

func (TrackFilter) ToModel

func (t TrackFilter) ToModel() *model.TrackFilter

type User

type User struct {
	ID          int    `json:"id"`
	UID         string `json:"uid"`
	Name        string `json:"name"`
	DisplayName string `json:"display_name"`
	Email       string `json:"email"`
}

func UserDTO

func UserDTO(user *model.User) User

func (*User) ToModel

func (u *User) ToModel() *model.User

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL