feat: find api service by id

This commit is contained in:
2025-05-31 17:38:29 +02:00
parent 2f58c01c24
commit 05a234b7a5
2 changed files with 31 additions and 0 deletions

View File

@ -8,6 +8,7 @@ package repository
import (
"context"
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
)
@ -96,6 +97,31 @@ func (q *Queries) GetApiServiceCID(ctx context.Context, clientID string) (ApiSer
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
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

View File

@ -11,6 +11,11 @@ WHERE client_id = $1
AND is_active = true
LIMIT 1;
-- name: GetApiServiceId :one
SELECT * FROM api_services
WHERE id = $1
LIMIT 1;
-- name: ListApiServices :many
SELECT * FROM api_services
ORDER BY created_at DESC;