genres

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutesWithGroup

func RegisterRoutesWithGroup(g *echo.Group, db *bun.DB, authMiddleware *auth.Middleware)

RegisterRoutesWithGroup registers genre routes on a pre-configured group.

Types

type ListGenresOptions

type ListGenresOptions struct {
	Limit      *int
	Offset     *int
	LibraryID  *int
	LibraryIDs []int // Filter by multiple library IDs (for access control)
	Search     *string
	// contains filtered or unexported fields
}

type ListGenresQuery

type ListGenresQuery 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 MergeGenresPayload

type MergeGenresPayload struct {
	SourceID int `json:"source_id" validate:"required,min=1"`
}

type RetrieveGenreOptions

type RetrieveGenreOptions struct {
	ID        *int
	Name      *string
	LibraryID *int
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(db *bun.DB) *Service

func (*Service) CleanupOrphanedGenres

func (svc *Service) CleanupOrphanedGenres(ctx context.Context) (int, error)

CleanupOrphanedGenres deletes genres with no book associations.

func (*Service) CreateGenre

func (svc *Service) CreateGenre(ctx context.Context, genre *models.Genre) error

func (*Service) DeleteGenre

func (svc *Service) DeleteGenre(ctx context.Context, genreID int) error

DeleteGenre deletes a genre and all book associations.

func (*Service) FindOrCreateGenre

func (svc *Service) FindOrCreateGenre(ctx context.Context, name string, libraryID int) (*models.Genre, error)

FindOrCreateGenre finds an existing genre or creates a new one (case-insensitive match).

func (*Service) GetBookCount

func (svc *Service) GetBookCount(ctx context.Context, genreID int) (int, error)

GetBookCount returns the count of books with this genre.

func (*Service) GetBooks

func (svc *Service) GetBooks(ctx context.Context, genreID int) ([]*models.Book, error)

GetBooks returns all books with this genre.

func (*Service) ListGenres

func (svc *Service) ListGenres(ctx context.Context, opts ListGenresOptions) ([]*models.Genre, error)

func (*Service) ListGenresWithTotal

func (svc *Service) ListGenresWithTotal(ctx context.Context, opts ListGenresOptions) ([]*models.Genre, int, error)

func (*Service) MergeGenres

func (svc *Service) MergeGenres(ctx context.Context, targetID, sourceID int) error

MergeGenres merges sourceGenre into targetGenre (moves all associations, deletes source).

func (*Service) RetrieveGenre

func (svc *Service) RetrieveGenre(ctx context.Context, opts RetrieveGenreOptions) (*models.Genre, error)

func (*Service) UpdateGenre

func (svc *Service) UpdateGenre(ctx context.Context, genre *models.Genre, opts UpdateGenreOptions) error

type UpdateGenreOptions

type UpdateGenreOptions struct {
	Columns []string
}

type UpdateGenrePayload

type UpdateGenrePayload struct {
	Name *string `json:"name,omitempty" validate:"omitempty,min=1,max=300"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL