init commit

This commit is contained in:
sentriz
2019-03-29 17:14:33 +00:00
commit e9c0f09d0c
527 changed files with 477627 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
package model
// Album represents the albums table
type Album struct {
BaseWithUUID
Artist Artist
ArtistID string
Title string
Tracks []Track
}
+8
View File
@@ -0,0 +1,8 @@
package model
// Artist represents the artists table
type Artist struct {
BaseWithUUID
Albums []Album
Name string `gorm:"unique;n"`
}
+31
View File
@@ -0,0 +1,31 @@
package model
import (
"time"
"github.com/jinzhu/gorm"
"github.com/twinj/uuid"
)
type CrudBase struct {
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
}
// Base is the base model with an auto incrementing primary key
type Base struct {
CrudBase
ID uint `gorm:"primary_key"`
}
// BaseWithUUID is the base model with an UUIDv4 primary key
type BaseWithUUID struct {
CrudBase
ID string `gorm:"primary_key"`
}
// BeforeCreate is called by GORM to set the UUID primary key
func (b *BaseWithUUID) BeforeCreate(scope *gorm.Scope) error {
return scope.SetColumn("ID", uuid.NewV4().String())
}
+10
View File
@@ -0,0 +1,10 @@
package model
// Cover represents the covers table
type Cover struct {
Base
Album Album
AlbumID string
Image []byte
Path string
}
+20
View File
@@ -0,0 +1,20 @@
package model
// Track represents the tracks table
type Track struct {
Base
Album Album
AlbumID string
Artist Artist
ArtistID string
Bitrate int
Codec string
DiscNumber int
Duration int
Title string
TotalDiscs int
TotalTracks int
TrackNumber int
Year int
Path string `gorm:"not null;unique"`
}