lists

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 11 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, _ *auth.Middleware)

RegisterRoutesWithGroup registers lists routes on a pre-configured group.

Types

type AddBooksOptions

type AddBooksOptions struct {
	ListID        int
	BookIDs       []int
	AddedByUserID int
}

type AddBooksPayload

type AddBooksPayload struct {
	BookIDs []int `json:"book_ids" validate:"required,min=1,max=500,dive,min=1"`
}

type CheckVisibilityQuery

type CheckVisibilityQuery struct {
	UserID int `query:"user_id" json:"user_id" validate:"required,min=1" tstype:"number"`
}

type CreateFromTemplatePayload

type CreateFromTemplatePayload struct {
}

type CreateListOptions

type CreateListOptions struct {
	UserID      int
	Name        string
	Description *string
	IsOrdered   bool
	DefaultSort string
}

type CreateListPayload

type CreateListPayload struct {
	Name        string  `json:"name" validate:"required,min=1,max=200"`
	Description *string `json:"description,omitempty" validate:"omitempty,max=2000" tstype:"string"`
	IsOrdered   bool    `json:"is_ordered"`
	DefaultSort *string `` /* 150-byte string literal not displayed */
}

Payloads for create/update endpoints.

type CreateShareOptions

type CreateShareOptions struct {
	ListID         int
	UserID         int
	Permission     string
	SharedByUserID int
}

type CreateSharePayload

type CreateSharePayload struct {
	UserID     int    `json:"user_id" validate:"required,min=1"`
	Permission string `json:"permission" validate:"required,oneof=viewer editor manager"`
}

type ListBooksOptions

type ListBooksOptions struct {
	ListID     int
	LibraryIDs []int // Filter by user's accessible libraries (nil = all)
	Sort       string
	Limit      *int
	Offset     *int
	// contains filtered or unexported fields
}

type ListBooksQuery

type ListBooksQuery 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   *string `` /* 155-byte string literal not displayed */
}

type ListListsOptions

type ListListsOptions struct {
	UserID int // Required - shows owned + shared lists
	Limit  *int
	Offset *int
	// contains filtered or unexported fields
}

type ListListsQuery

type ListListsQuery struct {
	Limit  int `query:"limit" json:"limit,omitempty" default:"50" validate:"min=1,max=100"`
	Offset int `query:"offset" json:"offset,omitempty" validate:"min=0"`
}

Query params for list endpoints.

type MoveBookPositionPayload

type MoveBookPositionPayload struct {
	Position int `json:"position" validate:"required,min=1"`
}

type RemoveBooksOptions

type RemoveBooksOptions struct {
	ListID  int
	BookIDs []int
}

type RemoveBooksPayload

type RemoveBooksPayload struct {
	BookIDs []int `json:"book_ids" validate:"required,min=1,max=500,dive,min=1"`
}

type ReorderBooksOptions

type ReorderBooksOptions struct {
	ListID  int
	BookIDs []int // New order - book IDs in desired sequence
}

type ReorderBooksPayload

type ReorderBooksPayload struct {
	BookIDs []int `json:"book_ids" validate:"required,min=1,max=500,dive,min=1"`
}

type RetrieveListOptions

type RetrieveListOptions struct {
	ID *int
}

type Service

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

func NewService

func NewService(db *bun.DB) *Service

func (*Service) AddBooks

func (svc *Service) AddBooks(ctx context.Context, opts AddBooksOptions) error

func (*Service) CanEdit

func (svc *Service) CanEdit(ctx context.Context, listID, userID int) (bool, error)

CanEdit returns true if the user can add/remove books.

func (*Service) CanManage

func (svc *Service) CanManage(ctx context.Context, listID, userID int) (bool, error)

CanManage returns true if the user can edit metadata and share.

func (*Service) CanView

func (svc *Service) CanView(ctx context.Context, listID, userID int) (bool, error)

CanView returns true if the user can view the list.

func (*Service) CheckBookVisibility

func (svc *Service) CheckBookVisibility(ctx context.Context, listID int, targetUserLibraryIDs []int) (visible, total int, err error)

CheckBookVisibility returns counts of visible/total books for a user.

func (*Service) CreateList

func (svc *Service) CreateList(ctx context.Context, opts CreateListOptions) (*models.List, error)

func (*Service) CreateShare

func (svc *Service) CreateShare(ctx context.Context, opts CreateShareOptions) (*models.ListShare, error)

func (*Service) DeleteList

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

func (*Service) DeleteShare

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

func (*Service) GetBookLists

func (svc *Service) GetBookLists(ctx context.Context, bookID, userID int) ([]*models.List, error)

GetBookLists returns lists that contain a specific book (for the user).

func (*Service) GetListBookCount

func (svc *Service) GetListBookCount(ctx context.Context, listID int, libraryIDs []int) (int, error)

GetListBookCount returns the number of books in a list visible to the user.

func (*Service) HasShare

func (svc *Service) HasShare(ctx context.Context, listID, userID int) (bool, error)

HasShare returns true if the user already has a share for the list.

func (*Service) IsOwner

func (svc *Service) IsOwner(ctx context.Context, listID, userID int) (bool, error)

IsOwner returns true if the user owns the list.

func (*Service) ListBooks

func (svc *Service) ListBooks(ctx context.Context, opts ListBooksOptions) ([]*models.ListBook, error)

func (*Service) ListBooksWithTotal

func (svc *Service) ListBooksWithTotal(ctx context.Context, opts ListBooksOptions) ([]*models.ListBook, int, error)

func (*Service) ListLists

func (svc *Service) ListLists(ctx context.Context, opts ListListsOptions) ([]*models.List, error)

func (*Service) ListListsWithTotal

func (svc *Service) ListListsWithTotal(ctx context.Context, opts ListListsOptions) ([]*models.List, int, error)

func (*Service) ListShares

func (svc *Service) ListShares(ctx context.Context, listID int) ([]*models.ListShare, error)

func (*Service) MoveBookToPosition

func (svc *Service) MoveBookToPosition(ctx context.Context, listID, bookID, position int) error

MoveBookToPosition moves a book to a specific position within an ordered list.

func (*Service) RemoveBooks

func (svc *Service) RemoveBooks(ctx context.Context, opts RemoveBooksOptions) error

func (*Service) ReorderBooks

func (svc *Service) ReorderBooks(ctx context.Context, opts ReorderBooksOptions) error

func (*Service) RetrieveList

func (svc *Service) RetrieveList(ctx context.Context, opts RetrieveListOptions) (*models.List, error)

func (*Service) UpdateBookListMemberships

func (svc *Service) UpdateBookListMemberships(ctx context.Context, bookID, userID int, listIDs []int) error

UpdateBookListMemberships replaces which lists a book belongs to. Only modifies lists the user can edit.

func (*Service) UpdateList

func (svc *Service) UpdateList(ctx context.Context, list *models.List, opts UpdateListOptions) error

func (*Service) UpdateShare

func (svc *Service) UpdateShare(ctx context.Context, shareID int, permission string) error

type UpdateBookListsPayload

type UpdateBookListsPayload struct {
	ListIDs []int `json:"list_ids" validate:"dive,min=1"`
}

type UpdateListOptions

type UpdateListOptions struct {
	Columns []string
}

type UpdateListPayload

type UpdateListPayload struct {
	Name        *string `json:"name,omitempty" validate:"omitempty,min=1,max=200" tstype:"string"`
	Description *string `json:"description,omitempty" validate:"omitempty,max=2000" tstype:"string"`
	IsOrdered   *bool   `json:"is_ordered,omitempty" tstype:"boolean"`
	DefaultSort *string `` /* 150-byte string literal not displayed */
}

type UpdateSharePayload

type UpdateSharePayload struct {
	Permission string `json:"permission" validate:"required,oneof=viewer editor manager"`
}

Jump to

Keyboard shortcuts

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