2024-03-11 01:25:15 +00:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
// versions:
|
|
|
|
// sqlc v1.25.0
|
|
|
|
// source: manage-oauth.sql
|
|
|
|
|
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
const getAppList = `-- name: GetAppList :many
|
|
|
|
SELECT subject, name, domain, owner, public, sso, active
|
|
|
|
FROM client_store
|
|
|
|
WHERE owner = ?
|
|
|
|
OR ? = 1
|
|
|
|
LIMIT 25 OFFSET ?
|
|
|
|
`
|
|
|
|
|
|
|
|
type GetAppListParams struct {
|
|
|
|
Owner string `json:"owner"`
|
|
|
|
Column2 interface{} `json:"column_2"`
|
|
|
|
Offset int64 `json:"offset"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type GetAppListRow struct {
|
2024-03-11 12:39:52 +00:00
|
|
|
Subject string `json:"subject"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Domain string `json:"domain"`
|
|
|
|
Owner string `json:"owner"`
|
|
|
|
Public bool `json:"public"`
|
|
|
|
Sso bool `json:"sso"`
|
|
|
|
Active bool `json:"active"`
|
2024-03-11 01:25:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) GetAppList(ctx context.Context, arg GetAppListParams) ([]GetAppListRow, error) {
|
|
|
|
rows, err := q.db.QueryContext(ctx, getAppList, arg.Owner, arg.Column2, arg.Offset)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
var items []GetAppListRow
|
|
|
|
for rows.Next() {
|
|
|
|
var i GetAppListRow
|
|
|
|
if err := rows.Scan(
|
|
|
|
&i.Subject,
|
|
|
|
&i.Name,
|
|
|
|
&i.Domain,
|
|
|
|
&i.Owner,
|
|
|
|
&i.Public,
|
|
|
|
&i.Sso,
|
|
|
|
&i.Active,
|
|
|
|
); 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 getClientInfo = `-- name: GetClientInfo :one
|
2024-03-11 12:39:52 +00:00
|
|
|
SELECT subject, name, secret, domain, owner, public, sso, active
|
2024-03-11 01:25:15 +00:00
|
|
|
FROM client_store
|
|
|
|
WHERE subject = ?
|
|
|
|
LIMIT 1
|
|
|
|
`
|
|
|
|
|
2024-03-11 12:39:52 +00:00
|
|
|
func (q *Queries) GetClientInfo(ctx context.Context, subject string) (ClientStore, error) {
|
2024-03-11 01:25:15 +00:00
|
|
|
row := q.db.QueryRowContext(ctx, getClientInfo, subject)
|
2024-03-11 12:39:52 +00:00
|
|
|
var i ClientStore
|
2024-03-11 01:25:15 +00:00
|
|
|
err := row.Scan(
|
2024-03-11 12:39:52 +00:00
|
|
|
&i.Subject,
|
2024-03-11 01:25:15 +00:00
|
|
|
&i.Name,
|
2024-03-11 12:39:52 +00:00
|
|
|
&i.Secret,
|
2024-03-11 01:25:15 +00:00
|
|
|
&i.Domain,
|
2024-03-11 12:39:52 +00:00
|
|
|
&i.Owner,
|
2024-03-11 01:25:15 +00:00
|
|
|
&i.Public,
|
|
|
|
&i.Sso,
|
|
|
|
&i.Active,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const insertClientApp = `-- name: InsertClientApp :exec
|
|
|
|
INSERT INTO client_store (subject, name, secret, domain, owner, public, sso, active)
|
|
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
|
|
`
|
|
|
|
|
|
|
|
type InsertClientAppParams struct {
|
2024-03-11 12:39:52 +00:00
|
|
|
Subject string `json:"subject"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Secret string `json:"secret"`
|
|
|
|
Domain string `json:"domain"`
|
|
|
|
Owner string `json:"owner"`
|
|
|
|
Public bool `json:"public"`
|
|
|
|
Sso bool `json:"sso"`
|
|
|
|
Active bool `json:"active"`
|
2024-03-11 01:25:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) InsertClientApp(ctx context.Context, arg InsertClientAppParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, insertClientApp,
|
|
|
|
arg.Subject,
|
|
|
|
arg.Name,
|
|
|
|
arg.Secret,
|
|
|
|
arg.Domain,
|
|
|
|
arg.Owner,
|
|
|
|
arg.Public,
|
|
|
|
arg.Sso,
|
|
|
|
arg.Active,
|
|
|
|
)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-03-12 21:04:25 +00:00
|
|
|
const resetClientAppSecret = `-- name: ResetClientAppSecret :exec
|
|
|
|
UPDATE client_store
|
|
|
|
SET secret = ?
|
|
|
|
WHERE subject = ?
|
|
|
|
AND owner = ?
|
|
|
|
`
|
|
|
|
|
|
|
|
type ResetClientAppSecretParams struct {
|
|
|
|
Secret string `json:"secret"`
|
|
|
|
Subject string `json:"subject"`
|
|
|
|
Owner string `json:"owner"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) ResetClientAppSecret(ctx context.Context, arg ResetClientAppSecretParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, resetClientAppSecret, arg.Secret, arg.Subject, arg.Owner)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-03-11 01:25:15 +00:00
|
|
|
const updateClientApp = `-- name: UpdateClientApp :exec
|
|
|
|
UPDATE client_store
|
|
|
|
SET name = ?,
|
|
|
|
domain = ?,
|
|
|
|
public = ?,
|
|
|
|
sso = ?,
|
|
|
|
active = ?
|
|
|
|
WHERE subject = ?
|
|
|
|
AND owner = ?
|
|
|
|
`
|
|
|
|
|
|
|
|
type UpdateClientAppParams struct {
|
2024-03-11 12:39:52 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
Domain string `json:"domain"`
|
|
|
|
Public bool `json:"public"`
|
|
|
|
Sso bool `json:"sso"`
|
|
|
|
Active bool `json:"active"`
|
|
|
|
Subject string `json:"subject"`
|
|
|
|
Owner string `json:"owner"`
|
2024-03-11 01:25:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) UpdateClientApp(ctx context.Context, arg UpdateClientAppParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, updateClientApp,
|
|
|
|
arg.Name,
|
|
|
|
arg.Domain,
|
|
|
|
arg.Public,
|
|
|
|
arg.Sso,
|
|
|
|
arg.Active,
|
|
|
|
arg.Subject,
|
|
|
|
arg.Owner,
|
|
|
|
)
|
|
|
|
return err
|
|
|
|
}
|