mirror of
https://github.com/Kyren223/eko.git
synced 2026-03-10 18:05:36 +00:00
215 lines
4.7 KiB
Go
215 lines
4.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
// source: users.sql
|
|
|
|
package data
|
|
|
|
import (
|
|
"context"
|
|
|
|
"crypto/ed25519"
|
|
"github.com/kyren223/eko/pkg/snowflake"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO users (
|
|
id, name, public_key
|
|
) VALUES (
|
|
?, ?, ?
|
|
)
|
|
RETURNING id, name, public_key, description, is_public_dm, is_deleted
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
ID snowflake.ID
|
|
Name string
|
|
PublicKey ed25519.PublicKey
|
|
}
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, createUser, arg.ID, arg.Name, arg.PublicKey)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.PublicKey,
|
|
&i.Description,
|
|
&i.IsPublicDM,
|
|
&i.IsDeleted,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteUser = `-- name: DeleteUser :exec
|
|
UPDATE users SET
|
|
is_deleted = true
|
|
WHERE id = ? AND is_deleted = false
|
|
`
|
|
|
|
func (q *Queries) DeleteUser(ctx context.Context, id snowflake.ID) error {
|
|
_, err := q.db.ExecContext(ctx, deleteUser, id)
|
|
return err
|
|
}
|
|
|
|
const getDeletedUserById = `-- name: GetDeletedUserById :one
|
|
SELECT id, name, public_key, description, is_public_dm, is_deleted FROM users
|
|
WHERE id = ? AND is_deleted = true
|
|
`
|
|
|
|
func (q *Queries) GetDeletedUserById(ctx context.Context, id snowflake.ID) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getDeletedUserById, id)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.PublicKey,
|
|
&i.Description,
|
|
&i.IsPublicDM,
|
|
&i.IsDeleted,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserById = `-- name: GetUserById :one
|
|
SELECT id, name, public_key, description, is_public_dm, is_deleted FROM users
|
|
WHERE id = ? AND is_deleted = false
|
|
`
|
|
|
|
func (q *Queries) GetUserById(ctx context.Context, id snowflake.ID) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserById, id)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.PublicKey,
|
|
&i.Description,
|
|
&i.IsPublicDM,
|
|
&i.IsDeleted,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByPublicKey = `-- name: GetUserByPublicKey :one
|
|
SELECT id, name, public_key, description, is_public_dm, is_deleted FROM users
|
|
WHERE public_key = ? AND is_deleted = false
|
|
`
|
|
|
|
func (q *Queries) GetUserByPublicKey(ctx context.Context, publicKey ed25519.PublicKey) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, getUserByPublicKey, publicKey)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.PublicKey,
|
|
&i.Description,
|
|
&i.IsPublicDM,
|
|
&i.IsDeleted,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const setUserDescription = `-- name: SetUserDescription :one
|
|
UPDATE users SET
|
|
description = ?
|
|
WHERE id = ? AND is_deleted = false
|
|
RETURNING id, name, public_key, description, is_public_dm, is_deleted
|
|
`
|
|
|
|
type SetUserDescriptionParams struct {
|
|
Description string
|
|
ID snowflake.ID
|
|
}
|
|
|
|
func (q *Queries) SetUserDescription(ctx context.Context, arg SetUserDescriptionParams) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, setUserDescription, arg.Description, arg.ID)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.PublicKey,
|
|
&i.Description,
|
|
&i.IsPublicDM,
|
|
&i.IsDeleted,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const setUserName = `-- name: SetUserName :one
|
|
UPDATE users SET
|
|
name = ?
|
|
WHERE id = ? AND is_deleted = false
|
|
RETURNING id, name, public_key, description, is_public_dm, is_deleted
|
|
`
|
|
|
|
type SetUserNameParams struct {
|
|
Name string
|
|
ID snowflake.ID
|
|
}
|
|
|
|
func (q *Queries) SetUserName(ctx context.Context, arg SetUserNameParams) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, setUserName, arg.Name, arg.ID)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.PublicKey,
|
|
&i.Description,
|
|
&i.IsPublicDM,
|
|
&i.IsDeleted,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const setUserPublicDMs = `-- name: SetUserPublicDMs :one
|
|
UPDATE users SET
|
|
is_public_dm = ?
|
|
WHERE id = ? AND is_deleted = false
|
|
RETURNING id, name, public_key, description, is_public_dm, is_deleted
|
|
`
|
|
|
|
type SetUserPublicDMsParams struct {
|
|
IsPublicDM bool
|
|
ID snowflake.ID
|
|
}
|
|
|
|
func (q *Queries) SetUserPublicDMs(ctx context.Context, arg SetUserPublicDMsParams) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, setUserPublicDMs, arg.IsPublicDM, arg.ID)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.PublicKey,
|
|
&i.Description,
|
|
&i.IsPublicDM,
|
|
&i.IsDeleted,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const setUserPublicKey = `-- name: SetUserPublicKey :one
|
|
UPDATE users SET
|
|
public_key = ?
|
|
WHERE id = ? AND is_deleted = false
|
|
RETURNING id, name, public_key, description, is_public_dm, is_deleted
|
|
`
|
|
|
|
type SetUserPublicKeyParams struct {
|
|
PublicKey ed25519.PublicKey
|
|
ID snowflake.ID
|
|
}
|
|
|
|
func (q *Queries) SetUserPublicKey(ctx context.Context, arg SetUserPublicKeyParams) (User, error) {
|
|
row := q.db.QueryRowContext(ctx, setUserPublicKey, arg.PublicKey, arg.ID)
|
|
var i User
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.PublicKey,
|
|
&i.Description,
|
|
&i.IsPublicDM,
|
|
&i.IsDeleted,
|
|
)
|
|
return i, err
|
|
}
|