entity

package
v0.0.0-...-c8675c7 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPassword = errors.New("invalid password")

	ErrPasswordLength = fmt.Errorf("password length must be 8 to 128: %w", ErrInvalidPassword)
	ErrPasswordFormat = fmt.Errorf("password must include at least 2 of the following: lowercase letters, uppercase letters, numbers, and symbols: %w", ErrInvalidPassword)
)

Functions

func IsValidPassword

func IsValidPassword(rawPassword RawPassword) error

Types

type Album

type Album struct {
	gormmodel.UUIDModel
	OwnerID  uuid.UUID `json:"-"`
	Owner    User      `gorm:"foreignKey:OwnerID" json:"-"`
	Name     string
	SortName *string
	Musics   []Music `gorm:"many2many:album_musics;"`
}

type Artist

type Artist struct {
	gormmodel.UUIDModel
	OwnerID  uuid.UUID `json:"-"`
	Owner    User      `gorm:"foreignKey:OwnerID" json:"-"`
	Name     string    `json:"name"`
	SortName *string   `json:"sort_name"`
}

type CharType

type CharType string
const (
	//アルファベット小文字
	CharTypeLowerAlpha CharType = "lower_alpha"
	//アルファベット大文字
	CharTypeUpperAlpha CharType = "upper_alpha"
	//数字
	CharTypeNumber CharType = "number"
	//その他文字
	CharTypeOther CharType = "other"
)

type Genre

type Genre struct {
	gormmodel.UUIDModel
	OwnerID uuid.UUID `json:"-"`
	Owner   User      `gorm:"foreignKey:OwnerID" json:"-"`
	Name    string    `json:"name"`
}

type LoginInfo

type LoginInfo struct {
	HashedPassword string `json:"-"`
	Salt           string `json:"-"`
}

func NewLoginInfo

func NewLoginInfo(rawPassword RawPassword) (LoginInfo, error)

func (LoginInfo) IsCorrectPassword

func (l LoginInfo) IsCorrectPassword(rawPassword RawPassword) bool

type Music

type Music struct {
	gormmodel.UUIDModel
	OwnerID          uuid.UUID `gorm:"index:idx_musics_file_hash,unique" json:"-"`
	Owner            User      `gorm:"foreignKey:OwnerID;" json:"-"`
	Name             string
	SortName         *string
	AlbumTrackNumber *int64
	Artists          []Artist `gorm:"many2many:music_artists;"`
	Score            int64
	Duration         time.Duration
	GenreID          *uuid.UUID
	Genre            *Genre

	// ----- cover info -----
	IsCover         bool
	OriginalMusicID *uuid.UUID

	// ----- raw data -----
	RawMetaData RawMusicMetadata `json:"-"`

	// ----- status -----
	Status    MusicStatus
	PlayCount int64

	FileHash string `gorm:"index:idx_musics_file_hash,unique"`
}

type MusicStatus

type MusicStatus string
const (
	Unknown             MusicStatus = "unknown"
	MetadataParsed      MusicStatus = "metadata_parsed"
	EncodeRetrying      MusicStatus = "encode_retrying"
	AudioEncoding       MusicStatus = "audio_encoding"
	AudioEncodeFinished MusicStatus = "audio_encode_finished"
	VideoEncoding       MusicStatus = "video_encoding"
	VideoEncoded        MusicStatus = "video_encoded"
)

type Playlist

type Playlist struct {
	gormmodel.UUIDModel
	OwnerID uuid.UUID `json:"-"`
	Owner   User      `gorm:"foreignKey:OwnerID" json:"-"`
	Musics  []Music   `gorm:"many2many:playlist_musics;"`
}

type RawMusicMetadata

type RawMusicMetadata struct {
	gormmodel.UUIDModel
	MusicID uuid.UUID

	Title            string `json:"title"`
	SortTitle        string `json:"sort_name"`
	Artist           string `json:"artist"`
	SortArtist       string `json:"sort_artist"`
	AlbumArtist      string `json:"album_artist"`
	Composer         string `json:"composer"`
	Album            string `json:"album"`
	SortAlbum        string `json:"sort_album"`
	Genre            string `json:"genre"`
	TrackNumber      int64
	TrackTotal       int64
	DiscNumber       int64
	DiscTotal        int64
	Duration         time.Duration
	CreationDatetime synchro.Time[tz.AsiaTokyo]

	TagList []RawMusicMetadataTag
}

func (RawMusicMetadata) ToEntity

func (r RawMusicMetadata) ToEntity(Owner User, fileName string) (music Music, album *Album, artist *Artist, genre *Genre)

type RawMusicMetadataTag

type RawMusicMetadataTag struct {
	gormmodel.UUIDModel
	RawMusicMetadataID uuid.UUID

	Key   string
	Value string
}

func NewRawMusicMetadataTags

func NewRawMusicMetadataTags(m map[string]any) []RawMusicMetadataTag

type RawPassword

type RawPassword string

type User

type User struct {
	gormmodel.UUIDModel
	UserName  string
	LoginInfo LoginInfo `gorm:"embedded" json:"-"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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