Files
geo/server/internal/tenant/repository/generated/kol_prompt.sql.go
T

490 lines
14 KiB
Go
Raw Normal View History

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: kol_prompt.sql
package generated
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const createKolPrompt = `-- name: CreateKolPrompt :one
INSERT INTO kol_prompts (tenant_id, package_id, name, platform_hint, sort_order, created_by, updated_by)
VALUES ($1::bigint, $2, $3,
$4, $5,
$6, $6)
RETURNING id, tenant_id, package_id, name, platform_hint, status, sort_order,
published_revision_no, draft_revision_no, created_by, updated_by,
created_at, updated_at
`
type CreateKolPromptParams struct {
TenantID int64 `json:"tenant_id"`
PackageID int64 `json:"package_id"`
Name string `json:"name"`
PlatformHint pgtype.Text `json:"platform_hint"`
SortOrder int32 `json:"sort_order"`
CreatedBy int64 `json:"created_by"`
}
type CreateKolPromptRow struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
PackageID int64 `json:"package_id"`
Name string `json:"name"`
PlatformHint pgtype.Text `json:"platform_hint"`
Status string `json:"status"`
SortOrder int32 `json:"sort_order"`
PublishedRevisionNo pgtype.Int4 `json:"published_revision_no"`
DraftRevisionNo pgtype.Int4 `json:"draft_revision_no"`
CreatedBy int64 `json:"created_by"`
UpdatedBy int64 `json:"updated_by"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
func (q *Queries) CreateKolPrompt(ctx context.Context, arg CreateKolPromptParams) (CreateKolPromptRow, error) {
row := q.db.QueryRow(ctx, createKolPrompt,
arg.TenantID,
arg.PackageID,
arg.Name,
arg.PlatformHint,
arg.SortOrder,
arg.CreatedBy,
)
var i CreateKolPromptRow
err := row.Scan(
&i.ID,
&i.TenantID,
&i.PackageID,
&i.Name,
&i.PlatformHint,
&i.Status,
&i.SortOrder,
&i.PublishedRevisionNo,
&i.DraftRevisionNo,
&i.CreatedBy,
&i.UpdatedBy,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const createKolPromptRevision = `-- name: CreateKolPromptRevision :one
INSERT INTO kol_prompt_revisions (tenant_id, prompt_id, revision_no, prompt_asset_key,
schema_json, card_config_json, created_by)
VALUES ($1::bigint, $2, $3,
$4, $5::jsonb,
$6::jsonb, $7)
RETURNING id, prompt_id, revision_no, prompt_asset_key, schema_json,
card_config_json, created_by, created_at
`
type CreateKolPromptRevisionParams struct {
TenantID int64 `json:"tenant_id"`
PromptID int64 `json:"prompt_id"`
RevisionNo int32 `json:"revision_no"`
PromptAssetKey string `json:"prompt_asset_key"`
SchemaJson []byte `json:"schema_json"`
CardConfigJson []byte `json:"card_config_json"`
CreatedBy int64 `json:"created_by"`
}
type CreateKolPromptRevisionRow struct {
ID int64 `json:"id"`
PromptID int64 `json:"prompt_id"`
RevisionNo int32 `json:"revision_no"`
PromptAssetKey string `json:"prompt_asset_key"`
SchemaJson []byte `json:"schema_json"`
CardConfigJson []byte `json:"card_config_json"`
CreatedBy int64 `json:"created_by"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
func (q *Queries) CreateKolPromptRevision(ctx context.Context, arg CreateKolPromptRevisionParams) (CreateKolPromptRevisionRow, error) {
row := q.db.QueryRow(ctx, createKolPromptRevision,
arg.TenantID,
arg.PromptID,
arg.RevisionNo,
arg.PromptAssetKey,
arg.SchemaJson,
arg.CardConfigJson,
arg.CreatedBy,
)
var i CreateKolPromptRevisionRow
err := row.Scan(
&i.ID,
&i.PromptID,
&i.RevisionNo,
&i.PromptAssetKey,
&i.SchemaJson,
&i.CardConfigJson,
&i.CreatedBy,
&i.CreatedAt,
)
return i, err
}
const getKolPromptByID = `-- name: GetKolPromptByID :one
SELECT id, tenant_id, package_id, name, platform_hint, status, sort_order,
published_revision_no, draft_revision_no, created_by, updated_by,
created_at, updated_at
FROM kol_prompts
WHERE id = $1
AND tenant_id = $2::bigint
AND deleted_at IS NULL
`
type GetKolPromptByIDParams struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
}
type GetKolPromptByIDRow struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
PackageID int64 `json:"package_id"`
Name string `json:"name"`
PlatformHint pgtype.Text `json:"platform_hint"`
Status string `json:"status"`
SortOrder int32 `json:"sort_order"`
PublishedRevisionNo pgtype.Int4 `json:"published_revision_no"`
DraftRevisionNo pgtype.Int4 `json:"draft_revision_no"`
CreatedBy int64 `json:"created_by"`
UpdatedBy int64 `json:"updated_by"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
func (q *Queries) GetKolPromptByID(ctx context.Context, arg GetKolPromptByIDParams) (GetKolPromptByIDRow, error) {
row := q.db.QueryRow(ctx, getKolPromptByID, arg.ID, arg.TenantID)
var i GetKolPromptByIDRow
err := row.Scan(
&i.ID,
&i.TenantID,
&i.PackageID,
&i.Name,
&i.PlatformHint,
&i.Status,
&i.SortOrder,
&i.PublishedRevisionNo,
&i.DraftRevisionNo,
&i.CreatedBy,
&i.UpdatedBy,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getKolPromptRevision = `-- name: GetKolPromptRevision :one
SELECT id, prompt_id, revision_no, prompt_asset_key, schema_json,
card_config_json, created_by, created_at
FROM kol_prompt_revisions
WHERE prompt_id = $1
AND revision_no = $2
AND tenant_id = $3::bigint
`
type GetKolPromptRevisionParams struct {
PromptID int64 `json:"prompt_id"`
RevisionNo int32 `json:"revision_no"`
TenantID int64 `json:"tenant_id"`
}
type GetKolPromptRevisionRow struct {
ID int64 `json:"id"`
PromptID int64 `json:"prompt_id"`
RevisionNo int32 `json:"revision_no"`
PromptAssetKey string `json:"prompt_asset_key"`
SchemaJson []byte `json:"schema_json"`
CardConfigJson []byte `json:"card_config_json"`
CreatedBy int64 `json:"created_by"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
func (q *Queries) GetKolPromptRevision(ctx context.Context, arg GetKolPromptRevisionParams) (GetKolPromptRevisionRow, error) {
row := q.db.QueryRow(ctx, getKolPromptRevision, arg.PromptID, arg.RevisionNo, arg.TenantID)
var i GetKolPromptRevisionRow
err := row.Scan(
&i.ID,
&i.PromptID,
&i.RevisionNo,
&i.PromptAssetKey,
&i.SchemaJson,
&i.CardConfigJson,
&i.CreatedBy,
&i.CreatedAt,
)
return i, err
}
const listActiveKolPromptsByPackage = `-- name: ListActiveKolPromptsByPackage :many
SELECT id, tenant_id, package_id, published_revision_no
FROM kol_prompts
WHERE package_id = $1
AND tenant_id = $2::bigint
AND status = 'active'
AND published_revision_no IS NOT NULL
AND deleted_at IS NULL
ORDER BY sort_order ASC
`
type ListActiveKolPromptsByPackageParams struct {
PackageID int64 `json:"package_id"`
TenantID int64 `json:"tenant_id"`
}
type ListActiveKolPromptsByPackageRow struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
PackageID int64 `json:"package_id"`
PublishedRevisionNo pgtype.Int4 `json:"published_revision_no"`
}
func (q *Queries) ListActiveKolPromptsByPackage(ctx context.Context, arg ListActiveKolPromptsByPackageParams) ([]ListActiveKolPromptsByPackageRow, error) {
rows, err := q.db.Query(ctx, listActiveKolPromptsByPackage, arg.PackageID, arg.TenantID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListActiveKolPromptsByPackageRow
for rows.Next() {
var i ListActiveKolPromptsByPackageRow
if err := rows.Scan(
&i.ID,
&i.TenantID,
&i.PackageID,
&i.PublishedRevisionNo,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listKolPromptsByPackage = `-- name: ListKolPromptsByPackage :many
SELECT id, tenant_id, package_id, name, platform_hint, status, sort_order,
published_revision_no, draft_revision_no, created_by, updated_by,
created_at, updated_at
FROM kol_prompts
WHERE package_id = $1
AND tenant_id = $2::bigint
AND deleted_at IS NULL
ORDER BY sort_order ASC, created_at ASC
`
type ListKolPromptsByPackageParams struct {
PackageID int64 `json:"package_id"`
TenantID int64 `json:"tenant_id"`
}
type ListKolPromptsByPackageRow struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
PackageID int64 `json:"package_id"`
Name string `json:"name"`
PlatformHint pgtype.Text `json:"platform_hint"`
Status string `json:"status"`
SortOrder int32 `json:"sort_order"`
PublishedRevisionNo pgtype.Int4 `json:"published_revision_no"`
DraftRevisionNo pgtype.Int4 `json:"draft_revision_no"`
CreatedBy int64 `json:"created_by"`
UpdatedBy int64 `json:"updated_by"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
func (q *Queries) ListKolPromptsByPackage(ctx context.Context, arg ListKolPromptsByPackageParams) ([]ListKolPromptsByPackageRow, error) {
rows, err := q.db.Query(ctx, listKolPromptsByPackage, arg.PackageID, arg.TenantID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListKolPromptsByPackageRow
for rows.Next() {
var i ListKolPromptsByPackageRow
if err := rows.Scan(
&i.ID,
&i.TenantID,
&i.PackageID,
&i.Name,
&i.PlatformHint,
&i.Status,
&i.SortOrder,
&i.PublishedRevisionNo,
&i.DraftRevisionNo,
&i.CreatedBy,
&i.UpdatedBy,
&i.CreatedAt,
&i.UpdatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const nextKolPromptRevisionNo = `-- name: NextKolPromptRevisionNo :one
SELECT COALESCE(MAX(revision_no), 0) + 1 AS next_revision_no
FROM kol_prompt_revisions
WHERE prompt_id = $1
AND tenant_id = $2::bigint
`
type NextKolPromptRevisionNoParams struct {
PromptID int64 `json:"prompt_id"`
TenantID int64 `json:"tenant_id"`
}
func (q *Queries) NextKolPromptRevisionNo(ctx context.Context, arg NextKolPromptRevisionNoParams) (int32, error) {
row := q.db.QueryRow(ctx, nextKolPromptRevisionNo, arg.PromptID, arg.TenantID)
var next_revision_no int32
err := row.Scan(&next_revision_no)
return next_revision_no, err
}
const softDeleteKolPrompt = `-- name: SoftDeleteKolPrompt :exec
UPDATE kol_prompts SET deleted_at = NOW()
WHERE id = $1
AND tenant_id = $2::bigint
AND deleted_at IS NULL
`
type SoftDeleteKolPromptParams struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
}
func (q *Queries) SoftDeleteKolPrompt(ctx context.Context, arg SoftDeleteKolPromptParams) error {
_, err := q.db.Exec(ctx, softDeleteKolPrompt, arg.ID, arg.TenantID)
return err
}
const updateKolPromptDraftRevision = `-- name: UpdateKolPromptDraftRevision :exec
UPDATE kol_prompts
SET draft_revision_no = $1,
updated_by = $2,
updated_at = NOW()
WHERE id = $3
AND tenant_id = $4::bigint
AND deleted_at IS NULL
`
type UpdateKolPromptDraftRevisionParams struct {
RevisionNo pgtype.Int4 `json:"revision_no"`
UpdatedBy int64 `json:"updated_by"`
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
}
func (q *Queries) UpdateKolPromptDraftRevision(ctx context.Context, arg UpdateKolPromptDraftRevisionParams) error {
_, err := q.db.Exec(ctx, updateKolPromptDraftRevision,
arg.RevisionNo,
arg.UpdatedBy,
arg.ID,
arg.TenantID,
)
return err
}
const updateKolPromptMetadata = `-- name: UpdateKolPromptMetadata :exec
UPDATE kol_prompts
SET name = $1,
platform_hint = $2,
sort_order = $3,
updated_by = $4,
updated_at = NOW()
WHERE id = $5
AND tenant_id = $6::bigint
AND deleted_at IS NULL
`
type UpdateKolPromptMetadataParams struct {
Name string `json:"name"`
PlatformHint pgtype.Text `json:"platform_hint"`
SortOrder int32 `json:"sort_order"`
UpdatedBy int64 `json:"updated_by"`
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
}
func (q *Queries) UpdateKolPromptMetadata(ctx context.Context, arg UpdateKolPromptMetadataParams) error {
_, err := q.db.Exec(ctx, updateKolPromptMetadata,
arg.Name,
arg.PlatformHint,
arg.SortOrder,
arg.UpdatedBy,
arg.ID,
arg.TenantID,
)
return err
}
const updateKolPromptPublishedRevision = `-- name: UpdateKolPromptPublishedRevision :exec
UPDATE kol_prompts
SET published_revision_no = $1,
status = 'active',
updated_by = $2,
updated_at = NOW()
WHERE id = $3
AND tenant_id = $4::bigint
AND deleted_at IS NULL
`
type UpdateKolPromptPublishedRevisionParams struct {
RevisionNo pgtype.Int4 `json:"revision_no"`
UpdatedBy int64 `json:"updated_by"`
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
}
func (q *Queries) UpdateKolPromptPublishedRevision(ctx context.Context, arg UpdateKolPromptPublishedRevisionParams) error {
_, err := q.db.Exec(ctx, updateKolPromptPublishedRevision,
arg.RevisionNo,
arg.UpdatedBy,
arg.ID,
arg.TenantID,
)
return err
}
const updateKolPromptStatus = `-- name: UpdateKolPromptStatus :exec
UPDATE kol_prompts
SET status = $1,
updated_by = $2,
updated_at = NOW()
WHERE id = $3
AND tenant_id = $4::bigint
AND deleted_at IS NULL
`
type UpdateKolPromptStatusParams struct {
Status string `json:"status"`
UpdatedBy int64 `json:"updated_by"`
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
}
func (q *Queries) UpdateKolPromptStatus(ctx context.Context, arg UpdateKolPromptStatusParams) error {
_, err := q.db.Exec(ctx, updateKolPromptStatus,
arg.Status,
arg.UpdatedBy,
arg.ID,
arg.TenantID,
)
return err
}