529 lines
11 KiB
Go
529 lines
11 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
// source: query.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
)
|
|
|
|
const addSvg = `-- name: AddSvg :exec
|
|
INSERT INTO svg_icon (svg) VALUES (?)
|
|
`
|
|
|
|
func (q *Queries) AddSvg(ctx context.Context, svg string) error {
|
|
_, err := q.db.ExecContext(ctx, addSvg, svg)
|
|
return err
|
|
}
|
|
|
|
const addUserPermission = `-- name: AddUserPermission :exec
|
|
INSERT INTO user_permission (user_id, permission) VALUES (?, ?)
|
|
`
|
|
|
|
type AddUserPermissionParams struct {
|
|
UserID string
|
|
Permission string
|
|
}
|
|
|
|
func (q *Queries) AddUserPermission(ctx context.Context, arg AddUserPermissionParams) error {
|
|
_, err := q.db.ExecContext(ctx, addUserPermission, arg.UserID, arg.Permission)
|
|
return err
|
|
}
|
|
|
|
const createCustomer = `-- name: CreateCustomer :exec
|
|
INSERT INTO customer (
|
|
id
|
|
,max_nkode_len
|
|
,min_nkode_len
|
|
,distinct_sets
|
|
,distinct_attributes
|
|
,lock_out
|
|
,expiration
|
|
,attribute_values
|
|
,set_values
|
|
,last_renew
|
|
,created_at
|
|
)
|
|
VALUES (?,?,?,?,?,?,?,?,?,?,?)
|
|
`
|
|
|
|
type CreateCustomerParams struct {
|
|
ID string
|
|
MaxNkodeLen int64
|
|
MinNkodeLen int64
|
|
DistinctSets int64
|
|
DistinctAttributes int64
|
|
LockOut int64
|
|
Expiration int64
|
|
AttributeValues []byte
|
|
SetValues []byte
|
|
LastRenew string
|
|
CreatedAt string
|
|
}
|
|
|
|
func (q *Queries) CreateCustomer(ctx context.Context, arg CreateCustomerParams) error {
|
|
_, err := q.db.ExecContext(ctx, createCustomer,
|
|
arg.ID,
|
|
arg.MaxNkodeLen,
|
|
arg.MinNkodeLen,
|
|
arg.DistinctSets,
|
|
arg.DistinctAttributes,
|
|
arg.LockOut,
|
|
arg.Expiration,
|
|
arg.AttributeValues,
|
|
arg.SetValues,
|
|
arg.LastRenew,
|
|
arg.CreatedAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const createUser = `-- name: CreateUser :exec
|
|
INSERT INTO user (
|
|
id
|
|
,email
|
|
,renew
|
|
,refresh_token
|
|
,customer_id
|
|
,code
|
|
,mask
|
|
,attributes_per_key
|
|
,number_of_keys
|
|
,alpha_key
|
|
,set_key
|
|
,pass_key
|
|
,mask_key
|
|
,salt
|
|
,max_nkode_len
|
|
,idx_interface
|
|
,svg_id_interface
|
|
,created_at
|
|
)
|
|
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
ID string
|
|
Email string
|
|
Renew int64
|
|
RefreshToken sql.NullString
|
|
CustomerID string
|
|
Code string
|
|
Mask string
|
|
AttributesPerKey int64
|
|
NumberOfKeys int64
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
PassKey []byte
|
|
MaskKey []byte
|
|
Salt []byte
|
|
MaxNkodeLen int64
|
|
IdxInterface []byte
|
|
SvgIDInterface []byte
|
|
CreatedAt sql.NullString
|
|
}
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) error {
|
|
_, err := q.db.ExecContext(ctx, createUser,
|
|
arg.ID,
|
|
arg.Email,
|
|
arg.Renew,
|
|
arg.RefreshToken,
|
|
arg.CustomerID,
|
|
arg.Code,
|
|
arg.Mask,
|
|
arg.AttributesPerKey,
|
|
arg.NumberOfKeys,
|
|
arg.AlphaKey,
|
|
arg.SetKey,
|
|
arg.PassKey,
|
|
arg.MaskKey,
|
|
arg.Salt,
|
|
arg.MaxNkodeLen,
|
|
arg.IdxInterface,
|
|
arg.SvgIDInterface,
|
|
arg.CreatedAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const getCustomer = `-- name: GetCustomer :one
|
|
SELECT
|
|
max_nkode_len
|
|
,min_nkode_len
|
|
,distinct_sets
|
|
,distinct_attributes
|
|
,lock_out
|
|
,expiration
|
|
,attribute_values
|
|
,set_values
|
|
FROM customer
|
|
WHERE id = ?
|
|
`
|
|
|
|
type GetCustomerRow struct {
|
|
MaxNkodeLen int64
|
|
MinNkodeLen int64
|
|
DistinctSets int64
|
|
DistinctAttributes int64
|
|
LockOut int64
|
|
Expiration int64
|
|
AttributeValues []byte
|
|
SetValues []byte
|
|
}
|
|
|
|
func (q *Queries) GetCustomer(ctx context.Context, id string) (GetCustomerRow, error) {
|
|
row := q.db.QueryRowContext(ctx, getCustomer, id)
|
|
var i GetCustomerRow
|
|
err := row.Scan(
|
|
&i.MaxNkodeLen,
|
|
&i.MinNkodeLen,
|
|
&i.DistinctSets,
|
|
&i.DistinctAttributes,
|
|
&i.LockOut,
|
|
&i.Expiration,
|
|
&i.AttributeValues,
|
|
&i.SetValues,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getSvgCount = `-- name: GetSvgCount :one
|
|
SELECT COUNT(*) as count FROM svg_icon
|
|
`
|
|
|
|
func (q *Queries) GetSvgCount(ctx context.Context) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, getSvgCount)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const getSvgId = `-- name: GetSvgId :one
|
|
SELECT svg
|
|
FROM svg_icon
|
|
WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) GetSvgId(ctx context.Context, id int64) (string, error) {
|
|
row := q.db.QueryRowContext(ctx, getSvgId, id)
|
|
var svg string
|
|
err := row.Scan(&svg)
|
|
return svg, err
|
|
}
|
|
|
|
const getUser = `-- name: GetUser :one
|
|
SELECT
|
|
id
|
|
,renew
|
|
,refresh_token
|
|
,code
|
|
,mask
|
|
,attributes_per_key
|
|
,number_of_keys
|
|
,alpha_key
|
|
,set_key
|
|
,pass_key
|
|
,mask_key
|
|
,salt
|
|
,max_nkode_len
|
|
,idx_interface
|
|
,svg_id_interface
|
|
FROM user
|
|
WHERE user.email = ? AND user.customer_id = ?
|
|
`
|
|
|
|
type GetUserParams struct {
|
|
Email string
|
|
CustomerID string
|
|
}
|
|
|
|
type GetUserRow struct {
|
|
ID string
|
|
Renew int64
|
|
RefreshToken sql.NullString
|
|
Code string
|
|
Mask string
|
|
AttributesPerKey int64
|
|
NumberOfKeys int64
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
PassKey []byte
|
|
MaskKey []byte
|
|
Salt []byte
|
|
MaxNkodeLen int64
|
|
IdxInterface []byte
|
|
SvgIDInterface []byte
|
|
}
|
|
|
|
func (q *Queries) GetUser(ctx context.Context, arg GetUserParams) (GetUserRow, error) {
|
|
row := q.db.QueryRowContext(ctx, getUser, arg.Email, arg.CustomerID)
|
|
var i GetUserRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Renew,
|
|
&i.RefreshToken,
|
|
&i.Code,
|
|
&i.Mask,
|
|
&i.AttributesPerKey,
|
|
&i.NumberOfKeys,
|
|
&i.AlphaKey,
|
|
&i.SetKey,
|
|
&i.PassKey,
|
|
&i.MaskKey,
|
|
&i.Salt,
|
|
&i.MaxNkodeLen,
|
|
&i.IdxInterface,
|
|
&i.SvgIDInterface,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserPermissions = `-- name: GetUserPermissions :many
|
|
SELECT permission FROM user_permission WHERE user_id = ?
|
|
`
|
|
|
|
func (q *Queries) GetUserPermissions(ctx context.Context, userID string) ([]string, error) {
|
|
rows, err := q.db.QueryContext(ctx, getUserPermissions, userID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []string
|
|
for rows.Next() {
|
|
var permission string
|
|
if err := rows.Scan(&permission); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, permission)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getUserRenew = `-- name: GetUserRenew :many
|
|
SELECT
|
|
id
|
|
,alpha_key
|
|
,set_key
|
|
,attributes_per_key
|
|
,number_of_keys
|
|
FROM user
|
|
WHERE customer_id = ?
|
|
`
|
|
|
|
type GetUserRenewRow struct {
|
|
ID string
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
AttributesPerKey int64
|
|
NumberOfKeys int64
|
|
}
|
|
|
|
func (q *Queries) GetUserRenew(ctx context.Context, customerID string) ([]GetUserRenewRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, getUserRenew, customerID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetUserRenewRow
|
|
for rows.Next() {
|
|
var i GetUserRenewRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.AlphaKey,
|
|
&i.SetKey,
|
|
&i.AttributesPerKey,
|
|
&i.NumberOfKeys,
|
|
); 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 refreshUserPasscode = `-- name: RefreshUserPasscode :exec
|
|
UPDATE user
|
|
SET
|
|
renew = ?
|
|
,code = ?
|
|
,mask = ?
|
|
,alpha_key = ?
|
|
,set_key = ?
|
|
,pass_key = ?
|
|
,mask_key = ?
|
|
,salt = ?
|
|
WHERE id = ?
|
|
`
|
|
|
|
type RefreshUserPasscodeParams struct {
|
|
Renew int64
|
|
Code string
|
|
Mask string
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
PassKey []byte
|
|
MaskKey []byte
|
|
Salt []byte
|
|
ID string
|
|
}
|
|
|
|
func (q *Queries) RefreshUserPasscode(ctx context.Context, arg RefreshUserPasscodeParams) error {
|
|
_, err := q.db.ExecContext(ctx, refreshUserPasscode,
|
|
arg.Renew,
|
|
arg.Code,
|
|
arg.Mask,
|
|
arg.AlphaKey,
|
|
arg.SetKey,
|
|
arg.PassKey,
|
|
arg.MaskKey,
|
|
arg.Salt,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const renewCustomer = `-- name: RenewCustomer :exec
|
|
UPDATE customer
|
|
SET attribute_values = ?, set_values = ?
|
|
WHERE id = ?
|
|
`
|
|
|
|
type RenewCustomerParams struct {
|
|
AttributeValues []byte
|
|
SetValues []byte
|
|
ID string
|
|
}
|
|
|
|
func (q *Queries) RenewCustomer(ctx context.Context, arg RenewCustomerParams) error {
|
|
_, err := q.db.ExecContext(ctx, renewCustomer, arg.AttributeValues, arg.SetValues, arg.ID)
|
|
return err
|
|
}
|
|
|
|
const renewUser = `-- name: RenewUser :exec
|
|
UPDATE user
|
|
SET alpha_key = ?, set_key = ?, renew = ?
|
|
WHERE id = ?
|
|
`
|
|
|
|
type RenewUserParams struct {
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
Renew int64
|
|
ID string
|
|
}
|
|
|
|
func (q *Queries) RenewUser(ctx context.Context, arg RenewUserParams) error {
|
|
_, err := q.db.ExecContext(ctx, renewUser,
|
|
arg.AlphaKey,
|
|
arg.SetKey,
|
|
arg.Renew,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateUser = `-- name: UpdateUser :exec
|
|
UPDATE user
|
|
SET renew = ?
|
|
,refresh_token = ?
|
|
,code = ?
|
|
,mask = ?
|
|
,attributes_per_key = ?
|
|
,number_of_keys = ?
|
|
,alpha_key = ?
|
|
,set_key = ?
|
|
,pass_key = ?
|
|
,mask_key = ?
|
|
,salt = ?
|
|
,max_nkode_len = ?
|
|
,idx_interface = ?
|
|
,svg_id_interface = ?
|
|
WHERE email = ? AND customer_id = ?
|
|
`
|
|
|
|
type UpdateUserParams struct {
|
|
Renew int64
|
|
RefreshToken sql.NullString
|
|
Code string
|
|
Mask string
|
|
AttributesPerKey int64
|
|
NumberOfKeys int64
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
PassKey []byte
|
|
MaskKey []byte
|
|
Salt []byte
|
|
MaxNkodeLen int64
|
|
IdxInterface []byte
|
|
SvgIDInterface []byte
|
|
Email string
|
|
CustomerID string
|
|
}
|
|
|
|
func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateUser,
|
|
arg.Renew,
|
|
arg.RefreshToken,
|
|
arg.Code,
|
|
arg.Mask,
|
|
arg.AttributesPerKey,
|
|
arg.NumberOfKeys,
|
|
arg.AlphaKey,
|
|
arg.SetKey,
|
|
arg.PassKey,
|
|
arg.MaskKey,
|
|
arg.Salt,
|
|
arg.MaxNkodeLen,
|
|
arg.IdxInterface,
|
|
arg.SvgIDInterface,
|
|
arg.Email,
|
|
arg.CustomerID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateUserInterface = `-- name: UpdateUserInterface :exec
|
|
UPDATE user SET idx_interface = ?, last_login = ? WHERE id = ?
|
|
`
|
|
|
|
type UpdateUserInterfaceParams struct {
|
|
IdxInterface []byte
|
|
LastLogin interface{}
|
|
ID string
|
|
}
|
|
|
|
func (q *Queries) UpdateUserInterface(ctx context.Context, arg UpdateUserInterfaceParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateUserInterface, arg.IdxInterface, arg.LastLogin, arg.ID)
|
|
return err
|
|
}
|
|
|
|
const updateUserRefreshToken = `-- name: UpdateUserRefreshToken :exec
|
|
UPDATE user SET refresh_token = ? WHERE id = ?
|
|
`
|
|
|
|
type UpdateUserRefreshTokenParams struct {
|
|
RefreshToken sql.NullString
|
|
ID string
|
|
}
|
|
|
|
func (q *Queries) UpdateUserRefreshToken(ctx context.Context, arg UpdateUserRefreshTokenParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateUserRefreshToken, arg.RefreshToken, arg.ID)
|
|
return err
|
|
}
|