135 lines
3.6 KiB
Go
135 lines
3.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: kol_assist.sql
|
|
|
|
package generated
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createKolAssistTask = `-- name: CreateKolAssistTask :exec
|
|
INSERT INTO kol_assist_tasks (id, tenant_id, kol_profile_id, prompt_id,
|
|
operator_id, task_type, status, request_json)
|
|
VALUES ($1, $2::bigint, $3,
|
|
$4, $5,
|
|
$6, 'queued', $7::jsonb)
|
|
`
|
|
|
|
type CreateKolAssistTaskParams struct {
|
|
ID string `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
KolProfileID int64 `json:"kol_profile_id"`
|
|
PromptID pgtype.Int8 `json:"prompt_id"`
|
|
OperatorID int64 `json:"operator_id"`
|
|
TaskType string `json:"task_type"`
|
|
RequestJson []byte `json:"request_json"`
|
|
}
|
|
|
|
func (q *Queries) CreateKolAssistTask(ctx context.Context, arg CreateKolAssistTaskParams) error {
|
|
_, err := q.db.Exec(ctx, createKolAssistTask,
|
|
arg.ID,
|
|
arg.TenantID,
|
|
arg.KolProfileID,
|
|
arg.PromptID,
|
|
arg.OperatorID,
|
|
arg.TaskType,
|
|
arg.RequestJson,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const getKolAssistTask = `-- name: GetKolAssistTask :one
|
|
SELECT id, tenant_id, kol_profile_id, prompt_id, operator_id, task_type,
|
|
status, request_json, result_json, error_message,
|
|
started_at, completed_at, created_at, updated_at
|
|
FROM kol_assist_tasks
|
|
WHERE id = $1
|
|
AND tenant_id = $2::bigint
|
|
`
|
|
|
|
type GetKolAssistTaskParams struct {
|
|
ID string `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) GetKolAssistTask(ctx context.Context, arg GetKolAssistTaskParams) (KolAssistTask, error) {
|
|
row := q.db.QueryRow(ctx, getKolAssistTask, arg.ID, arg.TenantID)
|
|
var i KolAssistTask
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.TenantID,
|
|
&i.KolProfileID,
|
|
&i.PromptID,
|
|
&i.OperatorID,
|
|
&i.TaskType,
|
|
&i.Status,
|
|
&i.RequestJson,
|
|
&i.ResultJson,
|
|
&i.ErrorMessage,
|
|
&i.StartedAt,
|
|
&i.CompletedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const markKolAssistCompleted = `-- name: MarkKolAssistCompleted :exec
|
|
UPDATE kol_assist_tasks
|
|
SET status = 'completed', result_json = $1::jsonb,
|
|
completed_at = NOW(), updated_at = NOW()
|
|
WHERE id = $2
|
|
AND tenant_id = $3::bigint
|
|
`
|
|
|
|
type MarkKolAssistCompletedParams struct {
|
|
ResultJson []byte `json:"result_json"`
|
|
ID string `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) MarkKolAssistCompleted(ctx context.Context, arg MarkKolAssistCompletedParams) error {
|
|
_, err := q.db.Exec(ctx, markKolAssistCompleted, arg.ResultJson, arg.ID, arg.TenantID)
|
|
return err
|
|
}
|
|
|
|
const markKolAssistFailed = `-- name: MarkKolAssistFailed :exec
|
|
UPDATE kol_assist_tasks
|
|
SET status = 'failed', error_message = $1,
|
|
completed_at = NOW(), updated_at = NOW()
|
|
WHERE id = $2
|
|
AND tenant_id = $3::bigint
|
|
`
|
|
|
|
type MarkKolAssistFailedParams struct {
|
|
ErrorMessage pgtype.Text `json:"error_message"`
|
|
ID string `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) MarkKolAssistFailed(ctx context.Context, arg MarkKolAssistFailedParams) error {
|
|
_, err := q.db.Exec(ctx, markKolAssistFailed, arg.ErrorMessage, arg.ID, arg.TenantID)
|
|
return err
|
|
}
|
|
|
|
const markKolAssistStarted = `-- name: MarkKolAssistStarted :exec
|
|
UPDATE kol_assist_tasks
|
|
SET status = 'running', started_at = NOW(), updated_at = NOW()
|
|
WHERE id = $1
|
|
AND tenant_id = $2::bigint
|
|
`
|
|
|
|
type MarkKolAssistStartedParams struct {
|
|
ID string `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) MarkKolAssistStarted(ctx context.Context, arg MarkKolAssistStartedParams) error {
|
|
_, err := q.db.Exec(ctx, markKolAssistStarted, arg.ID, arg.TenantID)
|
|
return err
|
|
}
|