整理model
All checks were successful
Go CI / test-and-build (push) Successful in 10s

This commit is contained in:
2026-04-06 17:40:56 +08:00
parent a067e8d17c
commit 3182b29932
9 changed files with 404 additions and 121 deletions

12
internal/model/dto.go Normal file
View File

@@ -0,0 +1,12 @@
package model
// SongDetail is a DTO for API responses with joined artist/album names.
// This is not a database model but a presentation-layer struct.
type SongDetail struct {
ID int `json:"id"`
Title string `json:"title"`
Artist string `json:"artist"`
Album string `json:"album"`
Duration int `json:"duration"`
Path string `json:"path"`
}

53
internal/model/model.go Normal file
View File

@@ -0,0 +1,53 @@
package model
import "time"
// Library represents a music library directory.
type Library struct {
ID int `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// MediaFile represents a single audio file on disk.
type MediaFile struct {
ID int `json:"id"`
Path string `json:"path"`
LibraryID int `json:"library_id"`
FileSize int64 `json:"file_size"`
Format string `json:"format"`
BitRate int `json:"bit_rate"`
SampleRate int `json:"sample_rate"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// Artist represents a music artist.
type Artist struct {
ID int `json:"id"`
Name string `json:"name"`
}
// Album represents a music album.
type Album struct {
ID int `json:"id"`
Title string `json:"title"`
ArtistID int `json:"artist_id"`
Cover string `json:"cover"`
Year int `json:"year"`
}
// Song represents a single track within an album.
type Song struct {
ID int `json:"id"`
Title string `json:"title"`
ArtistID int `json:"artist_id"`
AlbumID int `json:"album_id"`
Duration int `json:"duration"`
MediaFileID int `json:"media_file_id"`
TrackNumber int `json:"track_number"`
DiscNumber int `json:"disc_number"`
Genre string `json:"genre"`
}