Files
agentic-coding-workflow/internal/acp/sqlc/agent_kind_config_files.sql.go
T
2026-06-22 08:55:57 +08:00

108 lines
2.9 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: agent_kind_config_files.sql
package acpsqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const deleteAgentKindConfigFile = `-- name: DeleteAgentKindConfigFile :execrows
DELETE FROM acp_agent_kind_config_files
WHERE agent_kind_id = $1 AND rel_path = $2
`
type DeleteAgentKindConfigFileParams struct {
AgentKindID pgtype.UUID `json:"agent_kind_id"`
RelPath string `json:"rel_path"`
}
func (q *Queries) DeleteAgentKindConfigFile(ctx context.Context, arg DeleteAgentKindConfigFileParams) (int64, error) {
result, err := q.db.Exec(ctx, deleteAgentKindConfigFile, arg.AgentKindID, arg.RelPath)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}
const listAgentKindConfigFiles = `-- name: ListAgentKindConfigFiles :many
SELECT id, agent_kind_id, rel_path, encrypted_content, updated_by, created_at, updated_at, key_version
FROM acp_agent_kind_config_files
WHERE agent_kind_id = $1
ORDER BY rel_path ASC
`
func (q *Queries) ListAgentKindConfigFiles(ctx context.Context, agentKindID pgtype.UUID) ([]AcpAgentKindConfigFile, error) {
rows, err := q.db.Query(ctx, listAgentKindConfigFiles, agentKindID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []AcpAgentKindConfigFile
for rows.Next() {
var i AcpAgentKindConfigFile
if err := rows.Scan(
&i.ID,
&i.AgentKindID,
&i.RelPath,
&i.EncryptedContent,
&i.UpdatedBy,
&i.CreatedAt,
&i.UpdatedAt,
&i.KeyVersion,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const upsertAgentKindConfigFile = `-- name: UpsertAgentKindConfigFile :one
INSERT INTO acp_agent_kind_config_files (
id, agent_kind_id, rel_path, encrypted_content, updated_by
) VALUES ($1, $2, $3, $4, $5)
ON CONFLICT (agent_kind_id, rel_path) DO UPDATE
SET encrypted_content = EXCLUDED.encrypted_content,
updated_by = EXCLUDED.updated_by,
updated_at = now()
RETURNING id, agent_kind_id, rel_path, encrypted_content, updated_by, created_at, updated_at, key_version
`
type UpsertAgentKindConfigFileParams struct {
ID pgtype.UUID `json:"id"`
AgentKindID pgtype.UUID `json:"agent_kind_id"`
RelPath string `json:"rel_path"`
EncryptedContent []byte `json:"encrypted_content"`
UpdatedBy pgtype.UUID `json:"updated_by"`
}
func (q *Queries) UpsertAgentKindConfigFile(ctx context.Context, arg UpsertAgentKindConfigFileParams) (AcpAgentKindConfigFile, error) {
row := q.db.QueryRow(ctx, upsertAgentKindConfigFile,
arg.ID,
arg.AgentKindID,
arg.RelPath,
arg.EncryptedContent,
arg.UpdatedBy,
)
var i AcpAgentKindConfigFile
err := row.Scan(
&i.ID,
&i.AgentKindID,
&i.RelPath,
&i.EncryptedContent,
&i.UpdatedBy,
&i.CreatedAt,
&i.UpdatedAt,
&i.KeyVersion,
)
return i, err
}