Documentation
¶
Index ¶
- type APIKeyRepository
- func (r *APIKeyRepository) CountByUserAndName(ctx context.Context, userID int, name string) (int, error)
- func (r *APIKeyRepository) Create(ctx context.Context, key *apikey.APIKey) error
- func (r *APIKeyRepository) FindByIDAndUserID(ctx context.Context, id, userID int) (*apikey.APIKey, error)
- func (r *APIKeyRepository) FindByKeyID(ctx context.Context, keyID string) (*apikey.APIKey, error)
- func (r *APIKeyRepository) ListByUserID(ctx context.Context, userID int) ([]*apikey.APIKey, error)
- func (r *APIKeyRepository) RevokeByIDAndUserID(ctx context.Context, id, userID int, now time.Time) error
- func (r *APIKeyRepository) UpdateLastUsed(ctx context.Context, id int, now time.Time, ip string) error
- type AliasRepository
- func (r *AliasRepository) Create(ctx context.Context, a *alias.Alias) error
- func (r *AliasRepository) DeleteByContentID(ctx context.Context, contentID int) error
- func (r *AliasRepository) FindAll(ctx context.Context) ([]*alias.Alias, error)
- func (r *AliasRepository) FindByAlias(ctx context.Context, aliasStr string) (*alias.Alias, error)
- func (r *AliasRepository) FindByContentID(ctx context.Context, contentID int) ([]*alias.Alias, error)
- type CommentItem
- type CommentRepository
- func (r *CommentRepository) Count(ctx context.Context, userID int) (int, error)
- func (r *CommentRepository) Create(ctx context.Context, comment *contentdomain.Comment) error
- func (r *CommentRepository) Delete(ctx context.Context, id int) error
- func (r *CommentRepository) DeleteByUserID(ctx context.Context, userID int) error
- func (r *CommentRepository) GetByContentID(ctx context.Context, contentID int) ([]*contentdomain.Comment, error)
- func (r *CommentRepository) GetByContentIDForModeration(ctx context.Context, contentID int) ([]*contentdomain.Comment, error)
- func (r *CommentRepository) GetByID(ctx context.Context, id int) (*contentdomain.Comment, error)
- func (r *CommentRepository) GetByStatus(ctx context.Context, status contentdomain.CommentStatus) ([]*contentdomain.Comment, error)
- func (r *CommentRepository) GetByUserID(ctx context.Context, userID int) ([]*contentdomain.Comment, error)
- func (r *CommentRepository) UpdateStatus(ctx context.Context, id int, status contentdomain.CommentStatus) error
- type ContentItem
- type ContentRepository
- func (r *ContentRepository) AuthorExists(ctx context.Context, username string) (bool, error)
- func (r *ContentRepository) CheckSlugUnique(ctx context.Context, slug string, language string) (bool, error)
- func (r *ContentRepository) Count(ctx context.Context, userID int, filters contentdomain.ContentFilters) (int, error)
- func (r *ContentRepository) Create(ctx context.Context, content *contentdomain.Content) error
- func (r *ContentRepository) Delete(ctx context.Context, id int, userID int) error
- func (r *ContentRepository) DeleteByID(ctx context.Context, id int) error
- func (r *ContentRepository) GetAll(ctx context.Context, limit int, offset int) ([]*contentdomain.Content, error)
- func (r *ContentRepository) GetByID(ctx context.Context, id int) (*contentdomain.Content, error)
- func (r *ContentRepository) GetBySlug(ctx context.Context, slug string, language string) (*contentdomain.Content, error)
- func (r *ContentRepository) GetByUser(ctx context.Context, userID int, limit int, offset int) ([]*contentdomain.Content, error)
- func (r *ContentRepository) GetLatestByPostType(ctx context.Context, excludeID int, postType string, language string, ...) ([]*contentdomain.Content, error)
- func (r *ContentRepository) GetPublished(ctx context.Context, limit int, offset int) ([]*contentdomain.Content, error)
- func (r *ContentRepository) GetPublishedArchive(ctx context.Context, postType string, language string) ([]*contentdomain.ArchiveMonth, error)
- func (r *ContentRepository) GetPublishedAuthor(ctx context.Context, username string) (*contentdomain.PublishedAuthor, error)
- func (r *ContentRepository) GetPublishedAuthors(ctx context.Context, filters contentdomain.PublishedAuthorFilters) ([]*contentdomain.PublishedAuthor, error)
- func (r *ContentRepository) GetPublishedByAuthorUsername(ctx context.Context, username string, language string, limit int, offset int) ([]*contentdomain.Content, error)
- func (r *ContentRepository) GetPublishedByPostType(ctx context.Context, postType string, language string, year int, month int, ...) ([]*contentdomain.Content, error)
- func (r *ContentRepository) GetPublishedBySlug(ctx context.Context, slug string, language string) (*contentdomain.Content, error)
- func (r *ContentRepository) GetPublishedBySlugAny(ctx context.Context, slug string) (*contentdomain.Content, error)
- func (r *ContentRepository) GetPublishedByTag(ctx context.Context, tag string, language string, year int, month int, ...) ([]*contentdomain.Content, error)
- func (r *ContentRepository) GetPublishedCustomPostTypes(ctx context.Context) ([]string, error)
- func (r *ContentRepository) GetPublishedPages(ctx context.Context) ([]*contentdomain.Content, error)
- func (r *ContentRepository) GetPublishedTags(ctx context.Context) ([]string, error)
- func (r *ContentRepository) GetRelatedByTags(ctx context.Context, excludeID int, tags []string, postType string, ...) ([]*contentdomain.Content, error)
- func (r *ContentRepository) GetTranslations(ctx context.Context, translationGroupID int, excludeID int) ([]*contentdomain.Content, error)
- func (r *ContentRepository) ListByCursor(ctx context.Context, userID int, limit int, beforeID int, ...) ([]*contentdomain.Content, error)
- func (r *ContentRepository) ListByFilters(ctx context.Context, userID int, filters contentdomain.ContentFilters) ([]*contentdomain.Content, error)
- func (r *ContentRepository) SearchPublished(ctx context.Context, query string, limit int) ([]*contentdomain.Content, error)
- func (r *ContentRepository) TranslationGroupExists(ctx context.Context, id int) (bool, error)
- func (r *ContentRepository) Update(ctx context.Context, content *contentdomain.Content) error
- type DashboardRepository
- type MediaFile
- type MediaRepository
- func (r *MediaRepository) Count(ctx context.Context, search string, since time.Time) (int, error)
- func (r *MediaRepository) Create(ctx context.Context, media *mediadomain.Media) error
- func (r *MediaRepository) DeleteByID(ctx context.Context, id int) error
- func (r *MediaRepository) DeleteByOwner(ctx context.Context, id int, userID int) error
- func (r *MediaRepository) FindAllByCursor(ctx context.Context, limit int, beforeID int) ([]*mediadomain.Media, error)
- func (r *MediaRepository) FindAllByDateRangeByCursor(ctx context.Context, since time.Time, limit int, beforeID int) ([]*mediadomain.Media, error)
- func (r *MediaRepository) FindAllByFilenameAndDateRangeByCursor(ctx context.Context, filename string, since time.Time, limit int, beforeID int) ([]*mediadomain.Media, error)
- func (r *MediaRepository) FindAllByFilenameByCursor(ctx context.Context, filename string, limit int, beforeID int) ([]*mediadomain.Media, error)
- func (r *MediaRepository) FindByHash(ctx context.Context, hash string) (*mediadomain.Media, error)
- func (r *MediaRepository) FindByHashPrefix(ctx context.Context, prefix string) (*mediadomain.Media, error)
- func (r *MediaRepository) FindByID(ctx context.Context, id int) (*mediadomain.Media, error)
- func (r *MediaRepository) ListByCursor(ctx context.Context, userID int, limit int, beforeID int) ([]*mediadomain.Media, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKeyRepository ¶
type APIKeyRepository struct {
// contains filtered or unexported fields
}
APIKeyRepository persists API keys using SQLite syntax. Implements apikey.Repository.
func NewAPIKeyRepository ¶
func NewAPIKeyRepository(db *sql.DB) *APIKeyRepository
NewAPIKeyRepository creates a new SQLite API key repository.
func (*APIKeyRepository) CountByUserAndName ¶
func (r *APIKeyRepository) CountByUserAndName(ctx context.Context, userID int, name string) (int, error)
CountByUserAndName returns the number of non-revoked keys for a user with the given name. Used by the domain service to prevent duplicate key names.
func (*APIKeyRepository) Create ¶
Create inserts a new API key record and populates key.ID with the assigned row ID.
func (*APIKeyRepository) FindByIDAndUserID ¶
func (r *APIKeyRepository) FindByIDAndUserID(ctx context.Context, id, userID int) (*apikey.APIKey, error)
FindByIDAndUserID returns the single key matching (id, userID), or apikey.ErrKeyNotFound when no such row exists (covers nonexistent AND not-owned — identity scoping is enforced by the WHERE user_id predicate).
func (*APIKeyRepository) FindByKeyID ¶
FindByKeyID returns the key matching the public lookup prefix keyID, INCLUDING revoked and expired rows, or apikey.ErrKeyNotFound if none. The deliberate absence of a revoked_at IS NULL filter lets the Service distinguish a verified-but-revoked key from an unknown keyID.
func (*APIKeyRepository) ListByUserID ¶
ListByUserID returns all API keys owned by userID, newest-first. Returns an empty (non-nil) slice when the user has no keys.
func (*APIKeyRepository) RevokeByIDAndUserID ¶
func (r *APIKeyRepository) RevokeByIDAndUserID(ctx context.Context, id, userID int, now time.Time) error
RevokeByIDAndUserID sets revoked_at = now for the matching (id, userID) row. No rows-affected check is performed — the Service guards via FindByIDAndUserID first, so a 0-row UPDATE only happens under a benign race and is harmless.
func (*APIKeyRepository) UpdateLastUsed ¶
func (r *APIKeyRepository) UpdateLastUsed(ctx context.Context, id int, now time.Time, ip string) error
UpdateLastUsed sets last_used_at = now and last_used_ip = ip for the key id. Best-effort: no rows-affected check (the key was just verified to exist).
type AliasRepository ¶ added in v0.8.0
type AliasRepository struct {
// contains filtered or unexported fields
}
func NewAliasRepository ¶ added in v0.8.0
func NewAliasRepository(db *sql.DB) *AliasRepository
func (*AliasRepository) DeleteByContentID ¶ added in v0.8.0
func (r *AliasRepository) DeleteByContentID(ctx context.Context, contentID int) error
func (*AliasRepository) FindByAlias ¶ added in v0.8.0
func (*AliasRepository) FindByContentID ¶ added in v0.8.0
type CommentItem ¶
type CommentItem struct {
ID int `json:"id"`
ContentID int `json:"contentId"`
UserID int `json:"userId"`
Comment string `json:"comment"`
Status string `json:"status"`
Author sql.NullString `json:"author"`
Username sql.NullString `json:"username"`
Role sql.NullString `json:"role"`
ContentTitle sql.NullString `json:"contentTitle"`
ContentSlug sql.NullString `json:"contentSlug"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
CommentItem represents a comment in the database
type CommentRepository ¶
type CommentRepository struct {
// contains filtered or unexported fields
}
CommentRepository handles comment data operations
func NewCommentRepository ¶
func NewCommentRepository(db *sql.DB) *CommentRepository
NewCommentRepository creates a new comment repository
func (*CommentRepository) Create ¶
func (r *CommentRepository) Create(ctx context.Context, comment *contentdomain.Comment) error
func (*CommentRepository) Delete ¶
func (r *CommentRepository) Delete(ctx context.Context, id int) error
func (*CommentRepository) DeleteByUserID ¶
func (r *CommentRepository) DeleteByUserID(ctx context.Context, userID int) error
func (*CommentRepository) GetByContentID ¶
func (r *CommentRepository) GetByContentID(ctx context.Context, contentID int) ([]*contentdomain.Comment, error)
func (*CommentRepository) GetByContentIDForModeration ¶
func (r *CommentRepository) GetByContentIDForModeration(ctx context.Context, contentID int) ([]*contentdomain.Comment, error)
func (*CommentRepository) GetByID ¶
func (r *CommentRepository) GetByID(ctx context.Context, id int) (*contentdomain.Comment, error)
func (*CommentRepository) GetByStatus ¶ added in v0.3.0
func (r *CommentRepository) GetByStatus(ctx context.Context, status contentdomain.CommentStatus) ([]*contentdomain.Comment, error)
func (*CommentRepository) GetByUserID ¶
func (r *CommentRepository) GetByUserID(ctx context.Context, userID int) ([]*contentdomain.Comment, error)
func (*CommentRepository) UpdateStatus ¶
func (r *CommentRepository) UpdateStatus(ctx context.Context, id int, status contentdomain.CommentStatus) error
type ContentItem ¶
type ContentItem struct {
ID int `json:"id"`
UserID int `json:"userId"`
Title string `json:"title"`
Slug string `json:"slug"`
Content string `json:"content"`
Tags string `json:"tags"`
Status string `json:"status"`
Format string `json:"format"`
PostType string `json:"postType"`
MetaDescription *string `json:"metaDescription"`
OGTitle *string `json:"ogTitle"`
OGDescription *string `json:"ogDescription"`
AllowComments bool `json:"allowComments"`
CustomFields *string `json:"customFields"`
Language string `json:"language"`
TranslationGroupID sql.NullInt64 `json:"translationGroupId"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
ContentItem represents a content item in the database
type ContentRepository ¶
type ContentRepository struct {
// contains filtered or unexported fields
}
ContentRepository handles content data operations
func NewContentRepository ¶
func NewContentRepository(db *sql.DB) *ContentRepository
NewContentRepository creates a new content repository
func (*ContentRepository) AuthorExists ¶
func (*ContentRepository) CheckSlugUnique ¶
func (*ContentRepository) Count ¶ added in v0.8.0
func (r *ContentRepository) Count(ctx context.Context, userID int, filters contentdomain.ContentFilters) (int, error)
Count returns the number of content items matching the filters, using the same WHERE clause as ListByFilters (see buildContentFilterWhereClause). userID <= 0 counts across all users.
func (*ContentRepository) Create ¶
func (r *ContentRepository) Create(ctx context.Context, content *contentdomain.Content) error
func (*ContentRepository) DeleteByID ¶
func (r *ContentRepository) DeleteByID(ctx context.Context, id int) error
func (*ContentRepository) GetAll ¶
func (r *ContentRepository) GetAll(ctx context.Context, limit int, offset int) ([]*contentdomain.Content, error)
func (*ContentRepository) GetByID ¶
func (r *ContentRepository) GetByID(ctx context.Context, id int) (*contentdomain.Content, error)
func (*ContentRepository) GetBySlug ¶
func (r *ContentRepository) GetBySlug(ctx context.Context, slug string, language string) (*contentdomain.Content, error)
func (*ContentRepository) GetByUser ¶
func (r *ContentRepository) GetByUser(ctx context.Context, userID int, limit int, offset int) ([]*contentdomain.Content, error)
func (*ContentRepository) GetLatestByPostType ¶ added in v0.4.0
func (r *ContentRepository) GetLatestByPostType(ctx context.Context, excludeID int, postType string, language string, limit int) ([]*contentdomain.Content, error)
func (*ContentRepository) GetPublished ¶
func (r *ContentRepository) GetPublished(ctx context.Context, limit int, offset int) ([]*contentdomain.Content, error)
func (*ContentRepository) GetPublishedArchive ¶ added in v0.6.0
func (r *ContentRepository) GetPublishedArchive(ctx context.Context, postType string, language string) ([]*contentdomain.ArchiveMonth, error)
func (*ContentRepository) GetPublishedAuthor ¶ added in v0.7.0
func (r *ContentRepository) GetPublishedAuthor(ctx context.Context, username string) (*contentdomain.PublishedAuthor, error)
func (*ContentRepository) GetPublishedAuthors ¶ added in v0.5.0
func (r *ContentRepository) GetPublishedAuthors(ctx context.Context, filters contentdomain.PublishedAuthorFilters) ([]*contentdomain.PublishedAuthor, error)
func (*ContentRepository) GetPublishedByAuthorUsername ¶
func (r *ContentRepository) GetPublishedByAuthorUsername(ctx context.Context, username string, language string, limit int, offset int) ([]*contentdomain.Content, error)
func (*ContentRepository) GetPublishedByPostType ¶
func (*ContentRepository) GetPublishedBySlug ¶
func (r *ContentRepository) GetPublishedBySlug(ctx context.Context, slug string, language string) (*contentdomain.Content, error)
func (*ContentRepository) GetPublishedBySlugAny ¶
func (r *ContentRepository) GetPublishedBySlugAny(ctx context.Context, slug string) (*contentdomain.Content, error)
func (*ContentRepository) GetPublishedByTag ¶
func (*ContentRepository) GetPublishedCustomPostTypes ¶
func (r *ContentRepository) GetPublishedCustomPostTypes(ctx context.Context) ([]string, error)
func (*ContentRepository) GetPublishedPages ¶
func (r *ContentRepository) GetPublishedPages(ctx context.Context) ([]*contentdomain.Content, error)
func (*ContentRepository) GetPublishedTags ¶ added in v0.5.0
func (r *ContentRepository) GetPublishedTags(ctx context.Context) ([]string, error)
func (*ContentRepository) GetRelatedByTags ¶ added in v0.4.0
func (*ContentRepository) GetTranslations ¶
func (r *ContentRepository) GetTranslations(ctx context.Context, translationGroupID int, excludeID int) ([]*contentdomain.Content, error)
func (*ContentRepository) ListByCursor ¶
func (r *ContentRepository) ListByCursor(ctx context.Context, userID int, limit int, beforeID int, filters contentdomain.ContentFilters) ([]*contentdomain.Content, error)
func (*ContentRepository) ListByFilters ¶
func (r *ContentRepository) ListByFilters(ctx context.Context, userID int, filters contentdomain.ContentFilters) ([]*contentdomain.Content, error)
func (*ContentRepository) SearchPublished ¶
func (r *ContentRepository) SearchPublished(ctx context.Context, query string, limit int) ([]*contentdomain.Content, error)
func (*ContentRepository) TranslationGroupExists ¶
func (*ContentRepository) Update ¶
func (r *ContentRepository) Update(ctx context.Context, content *contentdomain.Content) error
type DashboardRepository ¶
type DashboardRepository struct {
// contains filtered or unexported fields
}
DashboardRepository handles dashboard data operations
func NewDashboardRepository ¶
func NewDashboardRepository(db *sql.DB) *DashboardRepository
NewDashboardRepository creates a new dashboard repository
type MediaFile ¶
type MediaFile struct {
ID int `json:"id"`
UserID int `json:"userId"`
Filename string `json:"filename"`
OriginalFilename string `json:"originalFilename"`
MimeType string `json:"mimeType"`
FileSize int64 `json:"fileSize"`
Width int `json:"width"`
Height int `json:"height"`
AltText string `json:"altText"`
IsWebP bool `json:"isWebp"`
FilePath string `json:"filePath"`
URL string `json:"url"`
Hash string `json:"hash"`
Variants sql.NullString `json:"variants"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
MediaFile represents a media file in the database
type MediaRepository ¶
type MediaRepository struct {
// contains filtered or unexported fields
}
MediaRepository handles media data operations
func NewMediaRepository ¶
func NewMediaRepository(db *sql.DB) *MediaRepository
NewMediaRepository creates a new media repository
func (*MediaRepository) Count ¶ added in v0.8.0
Count returns the total number of ALL media (not user-scoped) matching the given filename query and creation-time threshold (zero time means no date filter). It mirrors the WHERE clauses of the FindAll*ByCursor methods so a list's total always matches its rows.
func (*MediaRepository) Create ¶
func (r *MediaRepository) Create(ctx context.Context, media *mediadomain.Media) error
Create stores a new media file in the database
func (*MediaRepository) DeleteByID ¶
func (r *MediaRepository) DeleteByID(ctx context.Context, id int) error
DeleteByID removes a media file by ID (admin path)
func (*MediaRepository) DeleteByOwner ¶
DeleteByOwner removes a media file owned by a specific user
func (*MediaRepository) FindAllByCursor ¶ added in v0.8.0
func (r *MediaRepository) FindAllByCursor(ctx context.Context, limit int, beforeID int) ([]*mediadomain.Media, error)
FindAllByCursor returns ALL media (not user-scoped) in newest-first (id DESC) order using keyset pagination (beforeID <= 0 means first page; otherwise only rows with id < beforeID). Global counterpart of ListByCursor, used by the browser admin media library. The SELECT column list + row scan are reused via mediaColumns/mediaFrom/scanMediaRows.
func (*MediaRepository) FindAllByDateRangeByCursor ¶ added in v0.8.0
func (r *MediaRepository) FindAllByDateRangeByCursor( ctx context.Context, since time.Time, limit int, beforeID int, ) ([]*mediadomain.Media, error)
FindAllByDateRangeByCursor returns ALL media created since the given time in newest-first (id DESC) order using keyset pagination (beforeID <= 0 means first page).
func (*MediaRepository) FindAllByFilenameAndDateRangeByCursor ¶ added in v0.8.0
func (r *MediaRepository) FindAllByFilenameAndDateRangeByCursor( ctx context.Context, filename string, since time.Time, limit int, beforeID int, ) ([]*mediadomain.Media, error)
FindAllByFilenameAndDateRangeByCursor returns ALL media matching a filename query and created since the given time in newest-first (id DESC) order using keyset pagination (beforeID <= 0 means first page).
func (*MediaRepository) FindAllByFilenameByCursor ¶ added in v0.8.0
func (r *MediaRepository) FindAllByFilenameByCursor( ctx context.Context, filename string, limit int, beforeID int, ) ([]*mediadomain.Media, error)
FindAllByFilenameByCursor returns ALL media matching a filename query in newest-first (id DESC) order using keyset pagination (beforeID <= 0 means first page).
func (*MediaRepository) FindByHash ¶
func (r *MediaRepository) FindByHash(ctx context.Context, hash string) (*mediadomain.Media, error)
FindByHash retrieves a media file by its hash
func (*MediaRepository) FindByHashPrefix ¶
func (r *MediaRepository) FindByHashPrefix(ctx context.Context, prefix string) (*mediadomain.Media, error)
FindByHashPrefix retrieves a media file whose hash starts with the given prefix
func (*MediaRepository) FindByID ¶
func (r *MediaRepository) FindByID(ctx context.Context, id int) (*mediadomain.Media, error)
FindByID retrieves a media file by ID with uploader name
func (*MediaRepository) ListByCursor ¶
func (r *MediaRepository) ListByCursor(ctx context.Context, userID int, limit int, beforeID int) ([]*mediadomain.Media, error)
ListByCursor returns the caller's media in newest-first (id DESC) order using keyset pagination (beforeID <= 0 means first page; otherwise only rows with id < beforeID). The SELECT column list + row scan are reused via mediaColumns/mediaFrom/scanMediaRows.