/
Arsinenko
/
CompClubAPI_Go
Обзор
Документация
Войти
/
Arsinenko
/
CompClubAPI_Go
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
internal/database/gen/user.sql.go
147 строк
3 KB
Arsinenko
Update
08 ноя 2025, 13:12
08 ноя 2025, 13:12
2f36b0f
Код
Авторство
О чём код?
// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: user.sql package gen import ( "context" "database/sql" ) const createUser = `-- name: CreateUser :one insert into users (login, password_hash, role, balance) values ($1, $2, $3, $4) returning login, password_hash, role, balance ` type CreateUserParams struct { Login string PasswordHash string Role string Balance sql.NullString } func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) { row := q.db.QueryRowContext(ctx, createUser, arg.Login, arg.PasswordHash, arg.Role, arg.Balance, ) var i User err := row.Scan( &i.Login, &i.PasswordHash, &i.Role, &i.Balance, ) return i, err } const deleteUser = `-- name: DeleteUser :exec delete from users where login = $1 ` func (q *Queries) DeleteUser(ctx context.Context, login string) error { _, err := q.db.ExecContext(ctx, deleteUser, login) return err } const getAllUsers = `-- name: GetAllUsers :many select login, role, balance from users ` type GetAllUsersRow struct { Login string Role string Balance sql.NullString } func (q *Queries) GetAllUsers(ctx context.Context) ([]GetAllUsersRow, error) { rows, err := q.db.QueryContext(ctx, getAllUsers) if err != nil { return nil, err } defer rows.Close() var items []GetAllUsersRow for rows.Next() { var i GetAllUsersRow if err := rows.Scan(&i.Login, &i.Role, &i.Balance); 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 getUserByLogin = `-- name: GetUserByLogin :one select login, password_hash, role, balance from users where login = $1 ` func (q *Queries) GetUserByLogin(ctx context.Context, login string) (User, error) { row := q.db.QueryRowContext(ctx, getUserByLogin, login) var i User err := row.Scan( &i.Login, &i.PasswordHash, &i.Role, &i.Balance, ) return i, err } const updatePassword = `-- name: UpdatePassword :one update users set password_hash = $2 where login = $1 returning login, role, balance ` type UpdatePasswordParams struct { Login string PasswordHash string } type UpdatePasswordRow struct { Login string Role string Balance sql.NullString } func (q *Queries) UpdatePassword(ctx context.Context, arg UpdatePasswordParams) (UpdatePasswordRow, error) { row := q.db.QueryRowContext(ctx, updatePassword, arg.Login, arg.PasswordHash) var i UpdatePasswordRow err := row.Scan(&i.Login, &i.Role, &i.Balance) return i, err } const updateUserBalance = `-- name: UpdateUserBalance :one update users set balance = $2 where login = $1 returning login, role, balance ` type UpdateUserBalanceParams struct { Login string Balance sql.NullString } type UpdateUserBalanceRow struct { Login string Role string Balance sql.NullString } func (q *Queries) UpdateUserBalance(ctx context.Context, arg UpdateUserBalanceParams) (UpdateUserBalanceRow, error) { row := q.db.QueryRowContext(ctx, updateUserBalance, arg.Login, arg.Balance) var i UpdateUserBalanceRow err := row.Scan(&i.Login, &i.Role, &i.Balance) return i, err }