Documentation
¶
Index ¶
- func RegisterRoutesWithGroup(g *echo.Group, db *bun.DB, authMiddleware *auth.Middleware)
- type ListTagBooksResponse
- type ListTagsOptions
- type ListTagsQuery
- type ListTagsResponse
- type MergeTagsPayload
- type RetrieveTagOptions
- type Service
- func (svc *Service) CleanupOrphanedTags(ctx context.Context) ([]int, error)
- func (svc *Service) CreateTag(ctx context.Context, tag *models.Tag) error
- func (svc *Service) DeleteTag(ctx context.Context, tagID int) error
- func (svc *Service) FindOrCreateTag(ctx context.Context, name string, libraryID int) (*models.Tag, error)
- func (svc *Service) GetBookCount(ctx context.Context, tagID int) (int, error)
- func (svc *Service) GetBooks(ctx context.Context, tagID int) ([]*models.Book, error)
- func (svc *Service) GetBooksPaginated(ctx context.Context, tagID, limit, offset int) ([]*models.Book, int, error)
- func (svc *Service) ListTags(ctx context.Context, opts ListTagsOptions) ([]*models.Tag, error)
- func (svc *Service) ListTagsWithTotal(ctx context.Context, opts ListTagsOptions) ([]*models.Tag, int, error)
- func (svc *Service) MergeTags(ctx context.Context, targetID, sourceID int) error
- func (svc *Service) RetrieveTag(ctx context.Context, opts RetrieveTagOptions) (*models.Tag, error)
- func (svc *Service) UpdateTag(ctx context.Context, tag *models.Tag, opts UpdateTagOptions) error
- type SubResourceQuery
- type TagResponse
- type UpdateTagOptions
- type UpdateTagPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutesWithGroup ¶
RegisterRoutesWithGroup registers tag routes on a pre-configured group.
Types ¶
type ListTagBooksResponse ¶ added in v0.0.47
type ListTagBooksResponse struct {
Items []*models.Book `json:"items" tstype:"Book[]"`
Total int `json:"total"`
}
ListTagBooksResponse is the envelope for the tag books sub-resource.
type ListTagsOptions ¶
type ListTagsQuery ¶
type ListTagsQuery struct {
Limit int `query:"limit" json:"limit,omitempty" default:"24" validate:"min=1,max=50"`
Offset int `query:"offset" json:"offset,omitempty" validate:"min=0"`
LibraryID *int `query:"library_id" json:"library_id,omitempty" validate:"omitempty,min=1" tstype:"number"`
Search *string `query:"search" json:"search,omitempty" validate:"omitempty,max=100" tstype:"string"`
}
type ListTagsResponse ¶ added in v0.0.47
type ListTagsResponse struct {
Items []TagResponse `json:"items"`
Total int `json:"total"`
}
ListTagsResponse is the list-endpoint envelope.
type MergeTagsPayload ¶
type MergeTagsPayload struct {
SourceID int `json:"source_id" validate:"required,min=1"`
}
type RetrieveTagOptions ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) CleanupOrphanedTags ¶
CleanupOrphanedTags deletes tags with no book associations and returns the IDs of deleted tags. Callers must pass the returned IDs to searchService.DeleteFromTagIndex to keep tags_fts in sync — tags_fts is a virtual FTS5 table not tied to tags via foreign keys, so it is not cleaned up automatically.
func (*Service) FindOrCreateTag ¶
func (svc *Service) FindOrCreateTag(ctx context.Context, name string, libraryID int) (*models.Tag, error)
FindOrCreateTag finds an existing tag or creates a new one (case-insensitive match).
func (*Service) GetBookCount ¶
GetBookCount returns the count of books with this tag.
func (*Service) GetBooksPaginated ¶ added in v0.0.44
func (svc *Service) GetBooksPaginated(ctx context.Context, tagID, limit, offset int) ([]*models.Book, int, error)
GetBooksPaginated returns a paginated list of books with this tag.
func (*Service) ListTagsWithTotal ¶
func (*Service) MergeTags ¶
MergeTags merges sourceTag into targetTag (moves all associations, deletes source).
func (*Service) RetrieveTag ¶
type SubResourceQuery ¶ added in v0.0.44
type TagResponse ¶ added in v0.0.47
type TagResponse struct {
models.Tag `tstype:",extends"`
BookCount int `json:"book_count"`
Aliases []string `json:"aliases"`
}
TagResponse is the single-tag API response. It embeds the Tag model by value (so tygo emits `extends Tag`) and reshapes the aliases relation into a flat []string. BookCount and Aliases shadow the embedded model's same-json-tag fields, so the wire format is byte-identical to the previous anonymous struct.
type UpdateTagOptions ¶
type UpdateTagOptions struct {
Columns []string
}