spark-server/internal/module/music/entity/track.go
DESKTOP-L8OUL9F\gfl0034 53426af122 feat: 多广场 channel、音乐公开 API 与订阅 package_name
支持 square/squarenovel/squaresteps/squarehealth 实例与 category 筛选;音乐增加免登录 grouped/track;订阅套餐按 package_name 区分;补 migration 0030/0031 与 OpenAPI。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-30 09:02:28 +08:00

70 lines
2.2 KiB
Go

package entity
import "time"
const (
SettingMemberPreviewSeconds = "member_preview_seconds"
DefaultPreviewSeconds = 30
MaxCoverBytes = 5 << 20 // 5 MiB
MaxBackgroundBytes = 5 << 20 // 5 MiB
MaxAudioBytes = 50 << 20 // 50 MiB
)
// Track is one curated music item for the Spark music list.
type Track struct {
ID int64 `json:"id"`
Title string `json:"title"`
CoverKey string `json:"coverKey"`
AudioKey string `json:"audioKey"`
BackgroundKey string `json:"backgroundKey"`
CoverURL string `json:"coverUrl"`
AudioURL string `json:"audioUrl"`
BackgroundURL string `json:"backgroundUrl"`
RequireMember bool `json:"requireMember"`
SortOrder int `json:"sortOrder"`
Enabled bool `json:"enabled"`
CategoryIDs []int64 `json:"categoryIds"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// Category is a top-level or sub music category (parentID nil = 总分类).
type Category struct {
ID int64 `json:"id"`
ParentID *int64 `json:"parentId"`
Name string `json:"name"`
SortOrder int `json:"sortOrder"`
Enabled bool `json:"enabled"`
Children []Category `json:"children,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// Settings is the global music ops config.
type Settings struct {
MemberPreviewSeconds int `json:"memberPreviewSeconds"`
}
// Playlist is the client-facing payload.
type Playlist struct {
Items []Track `json:"items"`
Categories []Category `json:"categories"`
MemberPreviewSeconds int `json:"memberPreviewSeconds"`
}
// PlaylistGroup is one category (zone) with its enabled tracks.
// Maps to HuanXiu-style zoneAndZoneMusicList entries for Spark clients.
type PlaylistGroup struct {
CategoryID int64 `json:"categoryId"`
Name string `json:"name"`
ParentID *int64 `json:"parentId"`
Items []Track `json:"items"`
}
// GroupedPlaylist is categories-with-tracks for home tab migration.
type GroupedPlaylist struct {
Groups []PlaylistGroup `json:"groups"`
MemberPreviewSeconds int `json:"memberPreviewSeconds"`
}