feat(store): sqlc-запросы, dto TemplateDoc, Repository, интеграционные тесты CRUD

This commit is contained in:
2026-07-03 14:08:37 +07:00
parent 9c29d40269
commit 34bc49ee8c
15 changed files with 757 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
-- name: CreateAccount :one
INSERT INTO provider_accounts (id, project_id, provider, secret_enc, comment)
VALUES ($1, $2, $3, $4, $5)
RETURNING *;
-- name: GetAccount :one
SELECT * FROM provider_accounts WHERE id = $1 AND project_id = $2;
-- name: ListAccounts :many
SELECT * FROM provider_accounts WHERE project_id = $1 ORDER BY created_at;
-- name: DeleteAccount :exec
DELETE FROM provider_accounts WHERE id = $1 AND project_id = $2;
+4
View File
@@ -0,0 +1,4 @@
-- name: CreateCheckRun :one
INSERT INTO check_runs (id, domain_id, result)
VALUES ($1, $2, $3)
RETURNING *;
+13
View File
@@ -0,0 +1,13 @@
-- name: CreateDomain :one
INSERT INTO domains (id, project_id, provider_account_id, zone_name, zone_id, template_id)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING *;
-- name: GetDomain :one
SELECT * FROM domains WHERE id = $1 AND project_id = $2;
-- name: ListDomains :many
SELECT * FROM domains WHERE project_id = $1 ORDER BY created_at;
-- name: DeleteDomain :exec
DELETE FROM domains WHERE id = $1 AND project_id = $2;
+19
View File
@@ -0,0 +1,19 @@
-- name: CreateTemplate :one
INSERT INTO templates (id, project_id, name, doc, version)
VALUES ($1, $2, $3, $4, 1)
RETURNING *;
-- name: GetTemplate :one
SELECT * FROM templates WHERE id = $1 AND project_id = $2;
-- name: ListTemplates :many
SELECT * FROM templates WHERE project_id = $1 ORDER BY created_at;
-- name: UpdateTemplate :one
UPDATE templates
SET name = $3, doc = $4, version = version + 1, updated_at = now()
WHERE id = $1 AND project_id = $2
RETURNING *;
-- name: DeleteTemplate :exec
DELETE FROM templates WHERE id = $1 AND project_id = $2;