entity

package
v0.0.0-...-bd7327a Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package entity defines the data structures used in the application.

Package entity defines the data structures used in the application.

Package entity defines the data structures used in the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurSongInfo

type CurSongInfo struct {
	gorm.Model
	CurPlayingSongID uint `json:"cur_playing_song_id"`
	IsPlaying        bool `json:"is_playing"`
	PlaylistID       uint `json:"playlist_id"`
}

The CurSongInfo entity stores the information about the current playing song for a user, such as the ID of the song, whether it is playing or not, and the ID of the playlist it belongs to.

type Playlist

type Playlist struct {
	gorm.Model
	Name      string `json:"name" gorm:"type:varchar(64)"`
	Title     string `json:"title" gorm:"type:text"`
	HeadSong  uint   `json:"head_song"`
	TailSong  uint   `json:"tail_song"`
	CreatorID uint   `json:"creator_id"`
}

This struct represents a double-linked playlist entity with additional information about name, title and creator id.

type Song

type Song struct {
	gorm.Model
	Title     string        `json:"title" gorm:"type:text"`
	Artist    string        `json:"artist" gorm:"type:varchar(64)"`
	Duration  time.Duration `json:"duration" gorm:"not null"`
	Playlists []Playlist    `gorm:"many2many:playlist_songs;"`
}

The Song struct defines the properties of a music song entity in the system.

type SongNode

type SongNode struct {
	gorm.Model
	SongID     uint  `json:"song_id"`
	NextSongID uint  `json:"next_song_id"`
	PrevSongID uint  `json:"prev_song_id"`
	Song       *Song `json:"-" gorm:"foreignkey:SongID"`
}

This struct defines a song node entity that represents a single node in a double-linked playlist.

type User

type User struct {
	gorm.Model
	FirstName     string        `json:"first_name" gorm:"type:varchar(64)"`
	LastName      string        `json:"last_name" gorm:"type:varchar(64)"`
	Email         string        `json:"email" gorm:"unique;not null"`
	Password      string        `json:"password" gorm:"not null"`
	CurSongInfoID uint          `json:"cur_song_info_id"`
	CurSongInfo   CurSongInfo   `json:"-"`
	Playlists     pq.Int64Array `json:"playlists" gorm:"type:integer[]; foreignkey:CreatorID"`
}

The User entity stores user information such as first name, last name, email, password, current song and playlists.

Jump to

Keyboard shortcuts

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