feat: find api service by id
This commit is contained in:
@ -8,6 +8,7 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -96,6 +97,31 @@ func (q *Queries) GetApiServiceCID(ctx context.Context, clientID string) (ApiSer
|
|||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getApiServiceId = `-- name: GetApiServiceId :one
|
||||||
|
SELECT id, client_id, client_secret, name, redirect_uris, scopes, grant_types, created_at, updated_at, is_active, description FROM api_services
|
||||||
|
WHERE id = $1
|
||||||
|
LIMIT 1
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetApiServiceId(ctx context.Context, id uuid.UUID) (ApiService, error) {
|
||||||
|
row := q.db.QueryRow(ctx, getApiServiceId, id)
|
||||||
|
var i ApiService
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.ClientID,
|
||||||
|
&i.ClientSecret,
|
||||||
|
&i.Name,
|
||||||
|
&i.RedirectUris,
|
||||||
|
&i.Scopes,
|
||||||
|
&i.GrantTypes,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
|
&i.IsActive,
|
||||||
|
&i.Description,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
const listApiServices = `-- name: ListApiServices :many
|
const listApiServices = `-- name: ListApiServices :many
|
||||||
SELECT id, client_id, client_secret, name, redirect_uris, scopes, grant_types, created_at, updated_at, is_active, description FROM api_services
|
SELECT id, client_id, client_secret, name, redirect_uris, scopes, grant_types, created_at, updated_at, is_active, description FROM api_services
|
||||||
ORDER BY created_at DESC
|
ORDER BY created_at DESC
|
||||||
|
@ -11,6 +11,11 @@ WHERE client_id = $1
|
|||||||
AND is_active = true
|
AND is_active = true
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
|
-- name: GetApiServiceId :one
|
||||||
|
SELECT * FROM api_services
|
||||||
|
WHERE id = $1
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
-- name: ListApiServices :many
|
-- name: ListApiServices :many
|
||||||
SELECT * FROM api_services
|
SELECT * FROM api_services
|
||||||
ORDER BY created_at DESC;
|
ORDER BY created_at DESC;
|
||||||
|
Reference in New Issue
Block a user