Loggest thine Stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

155 lines
3.6 KiB

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.13.0
// source: stats.sql
package mysqlcore
import (
"context"
"database/sql"
"git.aiterp.net/stufflog3/stufflog3/ports/mysql/sqltypes"
)
const deleteAllItemStatProgressByStatId = `-- name: DeleteAllItemStatProgressByStatId :exec
DELETE FROM item_stat_progress WHERE stat_id = ?
`
func (q *Queries) DeleteAllItemStatProgressByStatId(ctx context.Context, statID int) error {
_, err := q.exec(ctx, q.deleteAllItemStatProgressByStatIdStmt, deleteAllItemStatProgressByStatId, statID)
return err
}
const deleteAllProjectRequirementStatByStatId = `-- name: DeleteAllProjectRequirementStatByStatId :exec
DELETE FROM project_requirement_stat WHERE stat_id = ?
`
func (q *Queries) DeleteAllProjectRequirementStatByStatId(ctx context.Context, statID int) error {
_, err := q.exec(ctx, q.deleteAllProjectRequirementStatByStatIdStmt, deleteAllProjectRequirementStatByStatId, statID)
return err
}
const deleteStat = `-- name: DeleteStat :exec
DELETE FROM stat WHERE id = ? AND scope_id = ?
`
type DeleteStatParams struct {
ID int
ScopeID int
}
func (q *Queries) DeleteStat(ctx context.Context, arg DeleteStatParams) error {
_, err := q.exec(ctx, q.deleteStatStmt, deleteStat, arg.ID, arg.ScopeID)
return err
}
const getStat = `-- name: GetStat :one
SELECT id, scope_id, name, description, weight, allowed_amounts FROM stat WHERE id = ? AND scope_id = ?
`
type GetStatParams struct {
ID int
ScopeID int
}
func (q *Queries) GetStat(ctx context.Context, arg GetStatParams) (Stat, error) {
row := q.queryRow(ctx, q.getStatStmt, getStat, arg.ID, arg.ScopeID)
var i Stat
err := row.Scan(
&i.ID,
&i.ScopeID,
&i.Name,
&i.Description,
&i.Weight,
&i.AllowedAmounts,
)
return i, err
}
const insertStat = `-- name: InsertStat :execresult
INSERT INTO stat (scope_id, name, description, weight, allowed_amounts)
VALUES (?, ?, ?, ?, ?)
`
type InsertStatParams struct {
ScopeID int
Name string
Description string
Weight float64
AllowedAmounts sqltypes.NullRawMessage
}
func (q *Queries) InsertStat(ctx context.Context, arg InsertStatParams) (sql.Result, error) {
return q.exec(ctx, q.insertStatStmt, insertStat,
arg.ScopeID,
arg.Name,
arg.Description,
arg.Weight,
arg.AllowedAmounts,
)
}
const listStats = `-- name: ListStats :many
SELECT id, scope_id, name, description, weight, allowed_amounts FROM stat WHERE scope_id = ? ORDER BY name
`
func (q *Queries) ListStats(ctx context.Context, scopeID int) ([]Stat, error) {
rows, err := q.query(ctx, q.listStatsStmt, listStats, scopeID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Stat{}
for rows.Next() {
var i Stat
if err := rows.Scan(
&i.ID,
&i.ScopeID,
&i.Name,
&i.Description,
&i.Weight,
&i.AllowedAmounts,
); 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 updateStat = `-- name: UpdateStat :exec
UPDATE stat
SET name = ?,
description = ?,
weight = ?,
allowed_amounts = ?
WHERE id = ? AND scope_id = ?
`
type UpdateStatParams struct {
Name string
Description string
Weight float64
AllowedAmounts sqltypes.NullRawMessage
ID int
ScopeID int
}
func (q *Queries) UpdateStat(ctx context.Context, arg UpdateStatParams) error {
_, err := q.exec(ctx, q.updateStatStmt, updateStat,
arg.Name,
arg.Description,
arg.Weight,
arg.AllowedAmounts,
arg.ID,
arg.ScopeID,
)
return err
}