Files
root 111498a65f feat: Refactor template handling and brand management
- Removed schema_json from article templates and related queries.
- Updated brand service to include website field in requests and responses.
- Simplified template wizard view by eliminating unused schema fields and related logic.
- Added tests for ark text format handling.
- Created migrations for dropping schema_json and adding website to brands.
2026-04-02 11:38:08 +08:00

127 lines
3.9 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: template.sql
package generated
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const getTemplateByID = `-- name: GetTemplateByID :one
SELECT id, scope, tenant_id, origin_type, template_key, template_name,
prompt_template, prompt_visibility, protected_prompt_asset_key,
card_config_json, status, version_no, created_at, updated_at
FROM article_templates
WHERE id = $1
AND (scope = 'platform' OR tenant_id = $2::bigint)
AND deleted_at IS NULL
`
type GetTemplateByIDParams struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
}
type GetTemplateByIDRow struct {
ID int64 `json:"id"`
Scope string `json:"scope"`
TenantID pgtype.Int8 `json:"tenant_id"`
OriginType string `json:"origin_type"`
TemplateKey string `json:"template_key"`
TemplateName string `json:"template_name"`
PromptTemplate pgtype.Text `json:"prompt_template"`
PromptVisibility string `json:"prompt_visibility"`
ProtectedPromptAssetKey pgtype.Text `json:"protected_prompt_asset_key"`
CardConfigJson []byte `json:"card_config_json"`
Status string `json:"status"`
VersionNo int32 `json:"version_no"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
func (q *Queries) GetTemplateByID(ctx context.Context, arg GetTemplateByIDParams) (GetTemplateByIDRow, error) {
row := q.db.QueryRow(ctx, getTemplateByID, arg.ID, arg.TenantID)
var i GetTemplateByIDRow
err := row.Scan(
&i.ID,
&i.Scope,
&i.TenantID,
&i.OriginType,
&i.TemplateKey,
&i.TemplateName,
&i.PromptTemplate,
&i.PromptVisibility,
&i.ProtectedPromptAssetKey,
&i.CardConfigJson,
&i.Status,
&i.VersionNo,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const listTemplates = `-- name: ListTemplates :many
SELECT id, scope, tenant_id, origin_type, template_key, template_name,
prompt_template, prompt_visibility, card_config_json,
status, version_no, created_at, updated_at
FROM article_templates
WHERE (scope = 'platform' OR tenant_id = $1::bigint)
AND status = 'active' AND deleted_at IS NULL
ORDER BY created_at DESC
`
type ListTemplatesRow struct {
ID int64 `json:"id"`
Scope string `json:"scope"`
TenantID pgtype.Int8 `json:"tenant_id"`
OriginType string `json:"origin_type"`
TemplateKey string `json:"template_key"`
TemplateName string `json:"template_name"`
PromptTemplate pgtype.Text `json:"prompt_template"`
PromptVisibility string `json:"prompt_visibility"`
CardConfigJson []byte `json:"card_config_json"`
Status string `json:"status"`
VersionNo int32 `json:"version_no"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
func (q *Queries) ListTemplates(ctx context.Context, tenantID int64) ([]ListTemplatesRow, error) {
rows, err := q.db.Query(ctx, listTemplates, tenantID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListTemplatesRow
for rows.Next() {
var i ListTemplatesRow
if err := rows.Scan(
&i.ID,
&i.Scope,
&i.TenantID,
&i.OriginType,
&i.TemplateKey,
&i.TemplateName,
&i.PromptTemplate,
&i.PromptVisibility,
&i.CardConfigJson,
&i.Status,
&i.VersionNo,
&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
}