de30497f59
- Implemented tenant and user management features including: - Tenant creation and management with associated migrations. - User creation and management with associated migrations. - Tenant membership management with associated migrations. - Platform user roles management with associated migrations. - Quota management with associated migrations. - Article and template management with associated migrations. - Added HTTP handlers for templates and workspaces. - Created tests for protected and public routes. - Introduced a script to check tenant scope in SQL queries. - Documented task plan for backend completion and frontend foundation.
97 lines
2.6 KiB
Go
97 lines
2.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: audit.sql
|
|
|
|
package generated
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createAuditLog = `-- name: CreateAuditLog :exec
|
|
INSERT INTO audit_logs (operator_id, tenant_id, module, action, before_json, after_json, result)
|
|
VALUES ($1, $2, $3, $4,
|
|
$5, $6, $7)
|
|
`
|
|
|
|
type CreateAuditLogParams struct {
|
|
OperatorID int64 `json:"operator_id"`
|
|
TenantID pgtype.Int8 `json:"tenant_id"`
|
|
Module string `json:"module"`
|
|
Action string `json:"action"`
|
|
BeforeJson []byte `json:"before_json"`
|
|
AfterJson []byte `json:"after_json"`
|
|
Result pgtype.Text `json:"result"`
|
|
}
|
|
|
|
func (q *Queries) CreateAuditLog(ctx context.Context, arg CreateAuditLogParams) error {
|
|
_, err := q.db.Exec(ctx, createAuditLog,
|
|
arg.OperatorID,
|
|
arg.TenantID,
|
|
arg.Module,
|
|
arg.Action,
|
|
arg.BeforeJson,
|
|
arg.AfterJson,
|
|
arg.Result,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const createGenerationTask = `-- name: CreateGenerationTask :one
|
|
INSERT INTO generation_tasks (tenant_id, article_id, quota_reservation_id, task_type, input_params_json, status)
|
|
VALUES ($1, $2, $3,
|
|
$4, $5, 'queued')
|
|
RETURNING id
|
|
`
|
|
|
|
type CreateGenerationTaskParams struct {
|
|
TenantID int64 `json:"tenant_id"`
|
|
ArticleID pgtype.Int8 `json:"article_id"`
|
|
QuotaReservationID pgtype.Int8 `json:"quota_reservation_id"`
|
|
TaskType string `json:"task_type"`
|
|
InputParamsJson []byte `json:"input_params_json"`
|
|
}
|
|
|
|
func (q *Queries) CreateGenerationTask(ctx context.Context, arg CreateGenerationTaskParams) (int64, error) {
|
|
row := q.db.QueryRow(ctx, createGenerationTask,
|
|
arg.TenantID,
|
|
arg.ArticleID,
|
|
arg.QuotaReservationID,
|
|
arg.TaskType,
|
|
arg.InputParamsJson,
|
|
)
|
|
var id int64
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const updateGenerationTaskStatus = `-- name: UpdateGenerationTaskStatus :exec
|
|
UPDATE generation_tasks SET status = $1, error_message = $2,
|
|
started_at = $3, completed_at = $4, updated_at = NOW()
|
|
WHERE id = $5 AND tenant_id = $6
|
|
`
|
|
|
|
type UpdateGenerationTaskStatusParams struct {
|
|
Status string `json:"status"`
|
|
ErrorMessage pgtype.Text `json:"error_message"`
|
|
StartedAt pgtype.Timestamptz `json:"started_at"`
|
|
CompletedAt pgtype.Timestamptz `json:"completed_at"`
|
|
ID int64 `json:"id"`
|
|
TenantID int64 `json:"tenant_id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateGenerationTaskStatus(ctx context.Context, arg UpdateGenerationTaskStatusParams) error {
|
|
_, err := q.db.Exec(ctx, updateGenerationTaskStatus,
|
|
arg.Status,
|
|
arg.ErrorMessage,
|
|
arg.StartedAt,
|
|
arg.CompletedAt,
|
|
arg.ID,
|
|
arg.TenantID,
|
|
)
|
|
return err
|
|
}
|