mirror of
https://github.com/JuLi0n21/pwa-player.git
synced 2026-04-19 23:40:05 +00:00
add sqlc, fix background img fetching
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package main
|
||||
|
||||
import v1 "backend/gen"
|
||||
import (
|
||||
v1 "backend/gen"
|
||||
"backend/internal/db"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Song represents a song entity
|
||||
// @Description Song represents a song with metadata
|
||||
type Song struct {
|
||||
BeatmapID int `json:"beatmap_id" example:"123456"`
|
||||
MD5Hash string `json:"md5_hash" example:"abcd1234efgh5678"`
|
||||
@@ -32,6 +34,24 @@ func (song Song) toProto() *v1.Song {
|
||||
}
|
||||
}
|
||||
|
||||
// The function `toSongProto` converts a `db.Beatmap` struct into a `v1.Song` struct by mapping the
|
||||
// fields and performing some data type conversions.
|
||||
func toSongProto(song db.Beatmap) *v1.Song {
|
||||
fmt.Println(song)
|
||||
return &v1.Song{
|
||||
BeatmapId: int32(safeInt64(song.Beatmapid)),
|
||||
Md5Hash: safeString(song.Md5hash),
|
||||
Title: safeString(song.Title),
|
||||
Artist: safeString(song.Artist),
|
||||
Creator: safeString(song.Creator),
|
||||
Folder: safeString(song.Folder),
|
||||
File: safeString(song.File),
|
||||
Audio: safeString(song.Audio),
|
||||
TotalTime: int64(safeInt64(song.Totaltime)),
|
||||
Image: extractImageFromFile(osuRoot, safeString(song.Folder), safeString(song.File)),
|
||||
}
|
||||
}
|
||||
|
||||
func toProtoSongs(local []Song) []*v1.Song {
|
||||
songs := make([]*v1.Song, len(local))
|
||||
for i, s := range local {
|
||||
|
||||
Reference in New Issue
Block a user