package database import ( "log" "gotest/internal/model" "gorm.io/gorm" ) // seedMusicData 初始化音乐数据(3 套音乐网站共用) func seedMusicData(db *gorm.DB) error { var count int64 db.Model(&model.Song{}).Count(&count) if count > 0 { log.Println("检测到已有音乐数据,跳过初始化") return nil } // 音乐分类(曲风) categories := []model.MusicCategory{ {Name: "Pop", Icon: "pop", Sort: 1}, {Name: "Rock", Icon: "rock", Sort: 2}, {Name: "Folk", Icon: "folk", Sort: 3}, {Name: "Electronic", Icon: "electronic", Sort: 4}, {Name: "Classical", Icon: "classical", Sort: 5}, {Name: "Hip-Hop", Icon: "hiphop", Sort: 6}, } for i := range categories { if err := db.Create(&categories[i]).Error; err != nil { return err } } // 歌曲数据 songs := []model.Song{ // 流行 {Title: "Across the Star Sea", Artist: "Lin Xiyin", Album: "Across the Star Sea", CategoryID: 1, CategoryName: "Pop", Duration: 245, PlayCount: 98000000, LikeCount: 850000, ReleaseDate: "2026-06-15", Language: "Chinese", Tags: `["Ballad","Piano","Healing"]`, Lyrics: "Across the star sea\nI wait for you on the other shore\nTime folds into a paper crane\nFlying into your heart", IsHot: true, IsNew: true, Sort: 1, Status: 1}, {Title: "Neon City", Artist: "Echo Band", Album: "City Lights", CategoryID: 1, CategoryName: "Pop", Duration: 198, PlayCount: 67000000, LikeCount: 520000, ReleaseDate: "2026-05-20", Language: "Chinese", Tags: `["Urban","Electropop","Energetic"]`, Lyrics: "Under the neon lights\nWe pass each other by\nEvery light tells a story", IsHot: true, Sort: 2, Status: 1}, {Title: "Summer Evening Breeze", Artist: "Su Nian", Album: "Summer Diary", CategoryID: 1, CategoryName: "Pop", Duration: 213, PlayCount: 45000000, LikeCount: 380000, ReleaseDate: "2026-07-01", Language: "Chinese", Tags: `["Summer","Fresh","Upbeat"]`, Lyrics: "The summer evening breeze blows gently\nCarrying the scent of gardenia\nWe ride our bicycles\nChasing the sunset", IsNew: true, Sort: 3, Status: 1}, // 摇滚 {Title: "Burning Wings", Artist: "Wildfire Band", Album: "Era of Flames", CategoryID: 2, CategoryName: "Rock", Duration: 312, PlayCount: 56000000, LikeCount: 680000, ReleaseDate: "2026-04-10", Language: "Chinese", Tags: `["Hard Rock","Passionate","Inspirational"]`, Lyrics: "Spread your burning wings\nBreak through all barriers\nEven if you fall\nFly toward the sun", IsHot: true, Sort: 1, Status: 1}, {Title: "Shattered Mirror", Artist: "Obsidian", Album: "Reflection", CategoryID: 2, CategoryName: "Rock", Duration: 267, PlayCount: 34000000, LikeCount: 420000, ReleaseDate: "2026-03-15", Language: "Chinese", Tags: `["Alternative Rock","Deep","Thoughtful"]`, Lyrics: "In the shattered mirror\nCountless versions of me appear\nWhich one is real", IsHot: true, Sort: 2, Status: 1}, {Title: "Road to Freedom", Artist: "The Vanguard", Album: "Boundless", CategoryID: 2, CategoryName: "Rock", Duration: 289, PlayCount: 28000000, LikeCount: 310000, ReleaseDate: "2026-06-28", Language: "Chinese", Tags: `["Punk","Freedom","Road"]`, Lyrics: "Step onto the road to freedom\nFloor it to the max\nWind howling in my ears", IsNew: true, Sort: 3, Status: 1}, // 民谣 {Title: "Clouds of Home", Artist: "Chen Muran", Album: "Faraway", CategoryID: 3, CategoryName: "Folk", Duration: 256, PlayCount: 78000000, LikeCount: 920000, ReleaseDate: "2026-05-01", Language: "Chinese", Tags: `["Nostalgia","Guitar","Warmth"]`, Lyrics: "The clouds of home\nDrift slowly by\nCarrying my longing\nLeft at home far away", IsHot: true, Sort: 1, Status: 1}, {Title: "Old Street Memories", Artist: "Jiangnan Yue", Album: "Songs in the Alley", CategoryID: 3, CategoryName: "Folk", Duration: 224, PlayCount: 42000000, LikeCount: 560000, ReleaseDate: "2026-04-22", Language: "Chinese", Tags: `["Vintage","Harmonica","Storytelling"]`, Lyrics: "The cobblestone road of the old street\nEtched with the lines of time\nGrandmother's rocking chair\nStill sways by the door", Sort: 2, Status: 1}, {Title: "Among the Mountains", Artist: "Voice of the Wind", Album: "Nature Recordings", CategoryID: 3, CategoryName: "Folk", Duration: 198, PlayCount: 31000000, LikeCount: 410000, ReleaseDate: "2026-07-05", Language: "Chinese", Tags: `["Nature","Bamboo Flute","Tranquility"]`, Lyrics: "The wind among the mountains\nCarries the scent of fresh grass\nA stream flows gently\nBirds are singing", IsNew: true, Sort: 3, Status: 1}, // 电子 {Title: "Cyber Dreamscape", Artist: "Neon Pulse", Album: "Digital Dreams", CategoryID: 4, CategoryName: "Electronic", Duration: 345, PlayCount: 89000000, LikeCount: 750000, ReleaseDate: "2026-06-18", Language: "Instrumental", Tags: `["Synth","Cyberpunk","Ambient"]`, Lyrics: "", IsHot: true, IsNew: true, Sort: 1, Status: 1}, {Title: "Pulsar", Artist: "Synthwave Lab", Album: "Cosmic Frequencies", CategoryID: 4, CategoryName: "Electronic", Duration: 278, PlayCount: 52000000, LikeCount: 480000, ReleaseDate: "2026-05-10", Language: "Instrumental", Tags: `["EDM","Space","Groove"]`, Lyrics: "", IsHot: true, Sort: 2, Status: 1}, {Title: "Data Flood", Artist: "CodeBeat", Album: "Binary", CategoryID: 4, CategoryName: "Electronic", Duration: 234, PlayCount: 36000000, LikeCount: 320000, ReleaseDate: "2026-07-08", Language: "Instrumental", Tags: `["Glitch","Tech","Experimental"]`, Lyrics: "", IsNew: true, Sort: 3, Status: 1}, // 古典 {Title: "Moonlight Sonata (Arrangement)", Artist: "Li Yunlang", Album: "Classical Reimagined", CategoryID: 5, CategoryName: "Classical", Duration: 420, PlayCount: 65000000, LikeCount: 880000, ReleaseDate: "2026-03-20", Language: "Instrumental", Tags: `["Piano","Beethoven","Arrangement"]`, Lyrics: "", IsHot: true, Sort: 1, Status: 1}, {Title: "Spring Waltz", Artist: "Vienna Philharmonic", Album: "Four Seasons", CategoryID: 5, CategoryName: "Classical", Duration: 387, PlayCount: 43000000, LikeCount: 560000, ReleaseDate: "2026-04-05", Language: "Instrumental", Tags: `["Orchestral","Waltz","Classic"]`, Lyrics: "", Sort: 2, Status: 1}, {Title: "Erquan Yingyue", Artist: "Hua Yanjun", Album: "Chinese Traditional Masterpieces", CategoryID: 5, CategoryName: "Classical", Duration: 512, PlayCount: 38000000, LikeCount: 620000, ReleaseDate: "2026-01-15", Language: "Instrumental", Tags: `["Erhu","Traditional","Masterpiece"]`, Lyrics: "", Sort: 3, Status: 1}, // 嘻哈 {Title: "Street Poet", Artist: "MC Fengmang", Album: "Underground Voice", CategoryID: 6, CategoryName: "Hip-Hop", Duration: 187, PlayCount: 72000000, LikeCount: 650000, ReleaseDate: "2026-06-25", Language: "Chinese", Tags: `["Rap","Street","Authentic"]`, Lyrics: "I am a street poet\nWriting diaries with rhymes\nEvery line is life\nEvery beat is a heartbeat", IsHot: true, IsNew: true, Sort: 1, Status: 1}, {Title: "Sleepless Night", Artist: "Trap Master", Album: "Midnight", CategoryID: 6, CategoryName: "Hip-Hop", Duration: 165, PlayCount: 48000000, LikeCount: 430000, ReleaseDate: "2026-05-15", Language: "English", Tags: `["Trap","Nightlife","Groove"]`, Lyrics: "Midnight city lights\nWe don't sleep tonight\nBeat drops heavy\nFlow so tight", IsHot: true, Sort: 2, Status: 1}, {Title: "Chasing Dreams", Artist: "New Generation", Album: "Breaking Free", CategoryID: 6, CategoryName: "Hip-Hop", Duration: 198, PlayCount: 35000000, LikeCount: 390000, ReleaseDate: "2026-07-03", Language: "Chinese", Tags: `["Inspirational","Flow","New Generation"]`, Lyrics: "From underground to the stage\nEvery step is hard\nBut dreams never lie\nAs long as you dare to chase", IsNew: true, Sort: 3, Status: 1}, } for i := range songs { if err := db.Create(&songs[i]).Error; err != nil { return err } } log.Printf("音乐数据初始化完成(%d 分类 + %d 歌曲)", len(categories), len(songs)) return nil }