mirror of
https://github.com/JuLi0n21/pwa-player.git
synced 2026-04-19 15:30:05 +00:00
229 lines
5.4 KiB
Go
229 lines
5.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: collection.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const getCollectionByName = `-- name: GetCollectionByName :many
|
|
SELECT c.Name, b.BeatmapId, b.MD5Hash, b.Title, b.Artist, b.Creator, b.Folder, b.File, b.Audio, b.TotalTime
|
|
FROM Collection c
|
|
JOIN Beatmap b ON c.MD5Hash = b.MD5Hash
|
|
WHERE c.Name = ?
|
|
LIMIT ? OFFSET ?
|
|
`
|
|
|
|
type GetCollectionByNameParams struct {
|
|
Name sql.NullString `json:"name"`
|
|
Limit int64 `json:"limit"`
|
|
Offset int64 `json:"offset"`
|
|
}
|
|
|
|
type GetCollectionByNameRow struct {
|
|
Name sql.NullString `json:"name"`
|
|
Beatmapid sql.NullInt64 `json:"beatmapid"`
|
|
Md5hash sql.NullString `json:"md5hash"`
|
|
Title sql.NullString `json:"title"`
|
|
Artist sql.NullString `json:"artist"`
|
|
Creator sql.NullString `json:"creator"`
|
|
Folder sql.NullString `json:"folder"`
|
|
File sql.NullString `json:"file"`
|
|
Audio sql.NullString `json:"audio"`
|
|
Totaltime sql.NullInt64 `json:"totaltime"`
|
|
}
|
|
|
|
func (q *Queries) GetCollectionByName(ctx context.Context, arg GetCollectionByNameParams) ([]GetCollectionByNameRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, getCollectionByName, arg.Name, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []GetCollectionByNameRow{}
|
|
for rows.Next() {
|
|
var i GetCollectionByNameRow
|
|
if err := rows.Scan(
|
|
&i.Name,
|
|
&i.Beatmapid,
|
|
&i.Md5hash,
|
|
&i.Title,
|
|
&i.Artist,
|
|
&i.Creator,
|
|
&i.Folder,
|
|
&i.File,
|
|
&i.Audio,
|
|
&i.Totaltime,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getCollectionByOffset = `-- name: GetCollectionByOffset :many
|
|
SELECT
|
|
c.Name,
|
|
b.BeatmapId,
|
|
b.MD5Hash,
|
|
b.Title,
|
|
b.Artist,
|
|
b.Creator,
|
|
b.Folder,
|
|
b.File,
|
|
b.Audio,
|
|
b.TotalTime
|
|
FROM Collection c
|
|
JOIN Beatmap b ON c.MD5Hash = b.MD5Hash
|
|
WHERE c.Name = (
|
|
SELECT Name
|
|
FROM Collection
|
|
GROUP BY Name
|
|
ORDER BY Name
|
|
LIMIT 1 OFFSET ?1
|
|
)
|
|
LIMIT ?2 OFFSET ?3
|
|
`
|
|
|
|
type GetCollectionByOffsetParams struct {
|
|
Offset int64 `json:"offset"`
|
|
Limit int64 `json:"limit"`
|
|
Offset_2 int64 `json:"offset_2"`
|
|
}
|
|
|
|
type GetCollectionByOffsetRow struct {
|
|
Name sql.NullString `json:"name"`
|
|
Beatmapid sql.NullInt64 `json:"beatmapid"`
|
|
Md5hash sql.NullString `json:"md5hash"`
|
|
Title sql.NullString `json:"title"`
|
|
Artist sql.NullString `json:"artist"`
|
|
Creator sql.NullString `json:"creator"`
|
|
Folder sql.NullString `json:"folder"`
|
|
File sql.NullString `json:"file"`
|
|
Audio sql.NullString `json:"audio"`
|
|
Totaltime sql.NullInt64 `json:"totaltime"`
|
|
}
|
|
|
|
func (q *Queries) GetCollectionByOffset(ctx context.Context, arg GetCollectionByOffsetParams) ([]GetCollectionByOffsetRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, getCollectionByOffset, arg.Offset, arg.Limit, arg.Offset_2)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []GetCollectionByOffsetRow{}
|
|
for rows.Next() {
|
|
var i GetCollectionByOffsetRow
|
|
if err := rows.Scan(
|
|
&i.Name,
|
|
&i.Beatmapid,
|
|
&i.Md5hash,
|
|
&i.Title,
|
|
&i.Artist,
|
|
&i.Creator,
|
|
&i.Folder,
|
|
&i.File,
|
|
&i.Audio,
|
|
&i.Totaltime,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getCollectionCountByName = `-- name: GetCollectionCountByName :one
|
|
SELECT COUNT(*) FROM Collection WHERE Name = ?
|
|
`
|
|
|
|
func (q *Queries) GetCollectionCountByName(ctx context.Context, name sql.NullString) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, getCollectionCountByName, name)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const insertCollection = `-- name: InsertCollection :exec
|
|
INSERT INTO Collection (Name, MD5Hash) VALUES (?, ?)
|
|
`
|
|
|
|
type InsertCollectionParams struct {
|
|
Name sql.NullString `json:"name"`
|
|
Md5hash sql.NullString `json:"md5hash"`
|
|
}
|
|
|
|
func (q *Queries) InsertCollection(ctx context.Context, arg InsertCollectionParams) error {
|
|
_, err := q.db.ExecContext(ctx, insertCollection, arg.Name, arg.Md5hash)
|
|
return err
|
|
}
|
|
|
|
const searchCollection = `-- name: SearchCollection :many
|
|
SELECT
|
|
c.Name,
|
|
COUNT(b.MD5Hash) AS Count,
|
|
b.Folder,
|
|
b.File
|
|
FROM Collection c
|
|
JOIN Beatmap b ON c.MD5Hash = b.MD5Hash
|
|
WHERE c.Name LIKE ?
|
|
GROUP BY c.Name
|
|
LIMIT ? OFFSET ?
|
|
`
|
|
|
|
type SearchCollectionParams struct {
|
|
Name sql.NullString `json:"name"`
|
|
Limit int64 `json:"limit"`
|
|
Offset int64 `json:"offset"`
|
|
}
|
|
|
|
type SearchCollectionRow struct {
|
|
Name sql.NullString `json:"name"`
|
|
Count int64 `json:"count"`
|
|
Folder sql.NullString `json:"folder"`
|
|
File sql.NullString `json:"file"`
|
|
}
|
|
|
|
func (q *Queries) SearchCollection(ctx context.Context, arg SearchCollectionParams) ([]SearchCollectionRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, searchCollection, arg.Name, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []SearchCollectionRow{}
|
|
for rows.Next() {
|
|
var i SearchCollectionRow
|
|
if err := rows.Scan(
|
|
&i.Name,
|
|
&i.Count,
|
|
&i.Folder,
|
|
&i.File,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|