Documentation
¶
Index ¶
- type AdminService
- type ContentFilters
- type ContentStatistics
- type CountRequest
- type CountResponse
- type ListContentsOption
- func WithCreatedAfter(t time.Time) ListContentsOption
- func WithCreatedBefore(t time.Time) ListContentsOption
- func WithDerivationType(derivationType string) ListContentsOption
- func WithDerivationTypes(derivationTypes ...string) ListContentsOption
- func WithDocumentType(documentType string) ListContentsOption
- func WithDocumentTypes(documentTypes ...string) ListContentsOption
- func WithIncludeDeleted() ListContentsOption
- func WithLimit(limit int) ListContentsOption
- func WithOffset(offset int) ListContentsOption
- func WithOwnerID(ownerID uuid.UUID) ListContentsOption
- func WithOwnerIDs(ownerIDs ...uuid.UUID) ListContentsOption
- func WithPagination(limit, offset int) ListContentsOption
- func WithSortBy(sortBy string) ListContentsOption
- func WithSortOrder(sortOrder string) ListContentsOption
- func WithStatus(status string) ListContentsOption
- func WithStatuses(statuses ...string) ListContentsOption
- func WithTenantID(tenantID uuid.UUID) ListContentsOption
- func WithTenantIDs(tenantIDs ...uuid.UUID) ListContentsOption
- func WithUpdatedAfter(t time.Time) ListContentsOption
- func WithUpdatedBefore(t time.Time) ListContentsOption
- type ListContentsRequest
- type ListContentsResponse
- type StatisticsOptions
- type StatisticsRequest
- type StatisticsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminService ¶
type AdminService interface {
// ListAllContents returns a paginated list of contents with optional filtering.
// Unlike the regular ListContent operation, this does not require owner_id or tenant_id.
ListAllContents(ctx context.Context, req ListContentsRequest) (*ListContentsResponse, error)
// CountContents returns the count of contents matching the given filters.
// This is useful for pagination and monitoring purposes.
CountContents(ctx context.Context, req CountRequest) (*CountResponse, error)
// GetStatistics returns aggregated statistics about contents.
// This provides breakdown by status, tenant, derivation type, etc.
GetStatistics(ctx context.Context, req StatisticsRequest) (*StatisticsResponse, error)
}
AdminService defines the interface for administrative content operations. These operations bypass normal owner_id/tenant_id restrictions and are intended for operational, monitoring, and bulk processing use cases.
IMPORTANT: Endpoints using this service should be protected with appropriate authentication and authorization middleware to ensure only authorized administrators can access these operations.
func New ¶
func New(repo simplecontent.Repository) AdminService
New creates a new AdminService instance that uses the provided repository.
type ContentFilters ¶
type ContentFilters struct {
// Identity filters
TenantID *uuid.UUID `json:"tenant_id,omitempty"`
TenantIDs []uuid.UUID `json:"tenant_ids,omitempty"`
OwnerID *uuid.UUID `json:"owner_id,omitempty"`
OwnerIDs []uuid.UUID `json:"owner_ids,omitempty"`
// Status filters
Status *string `json:"status,omitempty"`
Statuses []string `json:"statuses,omitempty"`
// Type filters
DerivationType *string `json:"derivation_type,omitempty"`
DerivationTypes []string `json:"derivation_types,omitempty"`
DocumentType *string `json:"document_type,omitempty"`
DocumentTypes []string `json:"document_types,omitempty"`
// Time range filters
CreatedAfter *time.Time `json:"created_after,omitempty"`
CreatedBefore *time.Time `json:"created_before,omitempty"`
UpdatedAfter *time.Time `json:"updated_after,omitempty"`
UpdatedBefore *time.Time `json:"updated_before,omitempty"`
// Pagination
Limit *int `json:"limit,omitempty"`
Offset *int `json:"offset,omitempty"`
// Sorting
SortBy *string `json:"sort_by,omitempty"` // created_at, updated_at, name
SortOrder *string `json:"sort_order,omitempty"` // asc, desc
// Special flags
IncludeDeleted bool `json:"include_deleted,omitempty"`
}
ContentFilters defines flexible filtering options for admin operations
type ContentStatistics ¶
type ContentStatistics struct {
TotalCount int64 `json:"total_count"`
ByStatus map[string]int64 `json:"by_status,omitempty"`
ByTenant map[string]int64 `json:"by_tenant,omitempty"`
ByDerivationType map[string]int64 `json:"by_derivation_type,omitempty"`
ByDocumentType map[string]int64 `json:"by_document_type,omitempty"`
OldestContent *time.Time `json:"oldest_content,omitempty"`
NewestContent *time.Time `json:"newest_content,omitempty"`
}
ContentStatistics provides aggregated statistics about content
type CountRequest ¶
type CountRequest struct {
Filters ContentFilters `json:"filters"`
}
CountRequest contains parameters for counting contents
type CountResponse ¶
type CountResponse struct {
Count int64 `json:"count"`
}
CountResponse contains the count result
type ListContentsOption ¶
type ListContentsOption func(*ContentFilters)
ListContentsOption provides functional options for listing contents
func WithCreatedAfter ¶
func WithCreatedAfter(t time.Time) ListContentsOption
WithCreatedAfter filters by created after time
func WithCreatedBefore ¶
func WithCreatedBefore(t time.Time) ListContentsOption
WithCreatedBefore filters by created before time
func WithDerivationType ¶
func WithDerivationType(derivationType string) ListContentsOption
WithDerivationType filters by derivation type
func WithDerivationTypes ¶
func WithDerivationTypes(derivationTypes ...string) ListContentsOption
WithDerivationTypes filters by multiple derivation types
func WithDocumentType ¶
func WithDocumentType(documentType string) ListContentsOption
WithDocumentType filters by document type
func WithDocumentTypes ¶
func WithDocumentTypes(documentTypes ...string) ListContentsOption
WithDocumentTypes filters by multiple document types
func WithIncludeDeleted ¶
func WithIncludeDeleted() ListContentsOption
WithIncludeDeleted includes deleted contents in results
func WithOffset ¶
func WithOffset(offset int) ListContentsOption
WithOffset sets the pagination offset
func WithOwnerID ¶
func WithOwnerID(ownerID uuid.UUID) ListContentsOption
WithOwnerID filters by owner ID
func WithOwnerIDs ¶
func WithOwnerIDs(ownerIDs ...uuid.UUID) ListContentsOption
WithOwnerIDs filters by multiple owner IDs
func WithPagination ¶
func WithPagination(limit, offset int) ListContentsOption
WithPagination sets both limit and offset
func WithSortOrder ¶
func WithSortOrder(sortOrder string) ListContentsOption
WithSortOrder sets the sort order
func WithStatuses ¶
func WithStatuses(statuses ...string) ListContentsOption
WithStatuses filters by multiple statuses
func WithTenantID ¶
func WithTenantID(tenantID uuid.UUID) ListContentsOption
WithTenantID filters by tenant ID
func WithTenantIDs ¶
func WithTenantIDs(tenantIDs ...uuid.UUID) ListContentsOption
WithTenantIDs filters by multiple tenant IDs
func WithUpdatedAfter ¶
func WithUpdatedAfter(t time.Time) ListContentsOption
WithUpdatedAfter filters by updated after time
func WithUpdatedBefore ¶
func WithUpdatedBefore(t time.Time) ListContentsOption
WithUpdatedBefore filters by updated before time
type ListContentsRequest ¶
type ListContentsRequest struct {
Filters ContentFilters `json:"filters"`
}
ListContentsRequest contains parameters for admin content listing
type ListContentsResponse ¶
type ListContentsResponse struct {
Contents []*simplecontent.Content `json:"contents"`
TotalCount *int64 `json:"total_count,omitempty"` // Optional, set if count was requested
Limit int `json:"limit"`
Offset int `json:"offset"`
HasMore bool `json:"has_more"`
}
ListContentsResponse contains the paginated list of contents
type StatisticsOptions ¶
type StatisticsOptions struct {
IncludeStatusBreakdown bool `json:"include_status_breakdown"`
IncludeTenantBreakdown bool `json:"include_tenant_breakdown"`
IncludeDerivationBreakdown bool `json:"include_derivation_breakdown"`
IncludeDocumentTypeBreakdown bool `json:"include_document_type_breakdown"`
IncludeTimeRange bool `json:"include_time_range"`
}
StatisticsOptions defines what statistics to compute
func DefaultStatisticsOptions ¶
func DefaultStatisticsOptions() StatisticsOptions
DefaultStatisticsOptions returns statistics options with all breakdowns enabled
type StatisticsRequest ¶
type StatisticsRequest struct {
Filters ContentFilters `json:"filters"`
Options StatisticsOptions `json:"options"`
}
StatisticsRequest contains parameters for retrieving content statistics
type StatisticsResponse ¶
type StatisticsResponse struct {
Statistics ContentStatistics `json:"statistics"`
ComputedAt time.Time `json:"computed_at"`
}
StatisticsResponse contains the statistics result