Documentation
¶
Index ¶
- func RegisterRoutes(g *echo.Group, db *bun.DB, authMiddleware *auth.Middleware, ...)
- type ListSeriesBooksQuery
- type ListSeriesBooksResponse
- type ListSeriesOptions
- type ListSeriesQuery
- type ListSeriesResponse
- type MergeSeriesPayload
- type RetrieveSeriesOptions
- type SeriesResponse
- type Service
- func (svc *Service) CreateSeries(ctx context.Context, series *models.Series) error
- func (svc *Service) DeleteSeries(ctx context.Context, seriesID int) ([]int, error)
- func (svc *Service) FindOrCreateSeries(ctx context.Context, name string, libraryID int, nameSource string) (*models.Series, error)
- func (svc *Service) GetSeriesBookCount(ctx context.Context, seriesID int) (int, error)
- func (svc *Service) ListSeries(ctx context.Context, opts ListSeriesOptions) ([]*models.Series, error)
- func (svc *Service) ListSeriesWithTotal(ctx context.Context, opts ListSeriesOptions) ([]*models.Series, int, error)
- func (svc *Service) MergeSeries(ctx context.Context, targetID, sourceID int) error
- func (svc *Service) RetrieveSeries(ctx context.Context, opts RetrieveSeriesOptions) (*models.Series, error)
- func (svc *Service) RetrieveSeriesByID(ctx context.Context, id int) (*models.Series, error)
- func (svc *Service) UpdateSeries(ctx context.Context, series *models.Series, opts UpdateSeriesOptions) error
- type UpdateSeriesOptions
- type UpdateSeriesPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶ added in v0.1.0
func RegisterRoutes(g *echo.Group, db *bun.DB, authMiddleware *auth.Middleware, bookService *books.Service, coverCache *covers.ThumbnailCache)
RegisterRoutes registers series routes on a group the server has already configured with authentication and the resource's read permission. bookService is required; pass a books service with app settings attached, or the delete handler's review recompute does nothing. The handler also uses it for series covers and book listings, so it takes the full service rather than the narrow review recompute interface.
Types ¶
type ListSeriesBooksQuery ¶ added in v0.4.0
type ListSeriesBooksQuery struct {
Limit int `query:"limit" json:"limit,omitempty" default:"24" validate:"min=1,max=100"`
Offset int `query:"offset" json:"offset,omitempty" validate:"min=0"`
// Sort is a book sort spec, as on GET /books. Omitted, books keep series order.
Sort string `query:"sort" json:"sort,omitempty" validate:"omitempty,max=200"`
}
ListSeriesBooksQuery is the query for the series books sub-resource.
type ListSeriesBooksResponse ¶ added in v0.0.47
type ListSeriesBooksResponse struct {
Items []*models.Book `json:"items" tstype:"Book[]"`
Total int `json:"total"`
}
ListSeriesBooksResponse is the envelope for the series books sub-resource.
type ListSeriesOptions ¶
type ListSeriesOptions struct {
Limit *int
Offset *int
LibraryID *int
LibraryIDs []int // Filter by multiple library IDs (for access control)
ListID *int // Filter to series with a book on this list
Search *string // FTS5 search query
Sort []sortspec.SortLevel // Defaults to name ascending
// MainFileTypes keeps only series with a book that has a main file of
// one of these types, and counts only those books. Nil means no filter;
// an empty list matches no series.
MainFileTypes []string
// contains filtered or unexported fields
}
type ListSeriesQuery ¶
type ListSeriesQuery struct {
Limit int `query:"limit" json:"limit,omitempty" default:"24" validate:"min=1,max=100"`
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"`
Sort string `query:"sort" json:"sort,omitempty" validate:"omitempty,max=200"`
}
type ListSeriesResponse ¶ added in v0.0.47
type ListSeriesResponse struct {
Items []SeriesResponse `json:"items"`
Total int `json:"total"`
}
ListSeriesResponse is the list-endpoint envelope.
type MergeSeriesPayload ¶
type MergeSeriesPayload struct {
SourceID int `json:"source_id" validate:"required,min=1"`
}
type RetrieveSeriesOptions ¶
type SeriesResponse ¶ added in v0.0.47
type SeriesResponse struct {
models.Series `tstype:",extends"`
BookCount int `json:"book_count"`
Aliases []string `json:"aliases"`
}
SeriesResponse is the single-series API response. It embeds the Series model by value (so tygo emits `extends Series`) 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. The name follows the project-wide {Entity}Response convention (ADR 0004); the revive "stutter" warning is a false positive because the entity is itself named "Series".
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) CreateSeries ¶
func (*Service) DeleteSeries ¶
DeleteSeries deletes a series. CASCADE on book_series.series_id removes the join rows. Returns the IDs of books that had a join row removed; callers should use these to recompute review state. The SELECT and DELETE run in a transaction so a concurrent insert into book_series cannot land between them — that row would be CASCADE-deleted but its book_id would be missing from the returned set.
Every member book gets series_source = manual before the delete, whatever the prior source was and even when it stays in other series, the same state the Edit form leaves after removing the membership. The delete is a deliberate user action, so an ordinary Scan must not bring the series back from a sidecar or the file, while Refresh all metadata and Reset to file metadata still may (ADR 0006). Only this service path is supported.
func (*Service) FindOrCreateSeries ¶
func (svc *Service) FindOrCreateSeries(ctx context.Context, name string, libraryID int, nameSource string) (*models.Series, error)
FindOrCreateSeries finds an existing series or creates a new one (case-insensitive match).
func (*Service) GetSeriesBookCount ¶
GetSeriesBookCount returns the number of books in a series.
func (*Service) ListSeries ¶
func (*Service) ListSeriesWithTotal ¶
func (*Service) MergeSeries ¶
MergeSeries merges sourceSeries into targetSeries (moves all books, deletes source).
A Series cannot be merged into itself. Where a Book is in both Series, the target's row stays and the source's is dropped, so the merge never violates ux_book_series_book_series. When the target's row has no number, it takes the source's number, end, and unit together, since a number group always comes from one place.
func (*Service) RetrieveSeries ¶
func (*Service) RetrieveSeriesByID ¶
RetrieveSeriesByID retrieves a series by its ID.
func (*Service) UpdateSeries ¶
type UpdateSeriesOptions ¶
type UpdateSeriesOptions struct {
Columns []string
}
type UpdateSeriesPayload ¶
type UpdateSeriesPayload struct {
Name *string `json:"name,omitempty" validate:"omitempty,max=300"`
SortName *string `json:"sort_name,omitempty" validate:"omitempty,max=300"`
Description *string `json:"description,omitempty" validate:"omitempty,max=2000"`
Aliases []string `json:"aliases,omitempty" validate:"omitempty,dive,min=1,max=300"`
}