forked from wrenn/wrenn
Consolidate 16 migrations into one with UUID columns for all entity
IDs. TEXT is kept only for polymorphic fields (audit_logs.actor_id,
resource_id) and template names. The id package now generates UUIDs
via google/uuid, with Format*/Parse* helpers for the prefixed wire
format (sb-{uuid}, usr-{uuid}, etc.). Auth context, services, and
handlers pass pgtype.UUID internally; conversion to/from prefixed
strings happens at API and RPC boundaries. Adds PlatformTeamID
(all-zeros UUID) for shared resources.
28 lines
750 B
Go
28 lines
750 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
|
|
"git.omukk.dev/wrenn/sandbox/internal/db"
|
|
)
|
|
|
|
// TemplateService provides template/snapshot operations shared between the
|
|
// REST API and the dashboard.
|
|
type TemplateService struct {
|
|
DB *db.Queries
|
|
}
|
|
|
|
// List returns all templates belonging to the given team. If typeFilter is
|
|
// non-empty, only templates of that type ("base" or "snapshot") are returned.
|
|
func (s *TemplateService) List(ctx context.Context, teamID pgtype.UUID, typeFilter string) ([]db.Template, error) {
|
|
if typeFilter != "" {
|
|
return s.DB.ListTemplatesByTeamAndType(ctx, db.ListTemplatesByTeamAndTypeParams{
|
|
TeamID: teamID,
|
|
Type: typeFilter,
|
|
})
|
|
}
|
|
return s.DB.ListTemplatesByTeam(ctx, teamID)
|
|
}
|