entities

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IndexFieldSep = "; "

	IdxFieldYear       = "year"
	IdxFieldISBN       = "isbn"
	IdxFieldTitle      = "title"
	IdxFieldAuthor     = "author"
	IdxFieldTranslator = "transl"
	IdxFieldSerie      = "serie"
	IdxFieldDate       = "date"
	IdxFieldGenre      = "genre"
	IdxFieldPublisher  = "publ"
	IdxFieldLang       = "lang"
	IdxFieldLib        = "lib"
)

Variables

This section is empty.

Functions

func BuildBookName added in v1.12.0

func BuildBookName(book BookIndex) (res string)

func BuildBookURL added in v1.12.0

func BuildBookURL(path, urlPrefix, pathPrefix string) string

func GenerateID added in v1.12.0

func GenerateID(args ...[]string) string

func GetFirstStr added in v1.12.0

func GetFirstStr(items []string) string

func NewBookIndexMapping

func NewBookIndexMapping() *mapping.IndexMappingImpl

func ParseFB2 added in v1.12.0

func ParseFB2(reader io.Reader, encoder LibEncodeType,
	rules ...fb2parse.HandlingRule,
) (res fb2parse.FB2File, err error)

func ParseYear added in v1.12.0

func ParseYear(date string) (res uint16)

func SliceHasString added in v1.12.0

func SliceHasString(haystack []string, needle string) bool

func TransformStr added in v1.12.0

func TransformStr(val string) string

Types

type BookIndex

type BookIndex struct {
	Year       uint16 `json:"year"`
	ID         string
	ISBN       string `json:"isbn"`
	Title      string `json:"title"`
	Author     string `json:"author"`
	Translator string `json:"transl"`
	Serie      string `json:"serie"`
	Date       string `json:"date"`
	Genre      string `json:"genre"`
	Publisher  string `json:"publ"`
	Lang       string `json:"lang"`
	Lib        string `json:"lib"`
}

func NewBookIndex

func NewBookIndex(match *search.DocumentMatch) BookIndex

func NewFB2Index added in v1.12.0

func NewFB2Index(fb2 *fb2parse.FB2File) (res BookIndex)

type BookInfo added in v1.12.0

type BookInfo struct {
	Offset         uint64    `json:"from"`
	Size           uint64    `json:"size"`
	SizeCompressed uint64    `json:"sizec"`
	LibName        string    `json:"lib"`
	Src            string    `json:"src"`
	Index          BookIndex `json:"-"`
	Details        struct {
		Images     []fb2parse.FB2Binary
		Annotation string
	} `json:"-"`
}

func (*BookInfo) ReadDetails added in v1.12.0

func (b *BookInfo) ReadDetails(fb2 *fb2parse.FB2File)

type CntAtomic32

type CntAtomic32 uint32

func (*CntAtomic32) Inc

func (c *CntAtomic32) Inc(delta uint32) uint32

func (*CntAtomic32) Total

func (c *CntAtomic32) Total() uint32

type GenreFreq added in v1.13.0

type GenreFreq struct {
	Name string
	Cnt  uint32
}

type GenresIndex added in v1.13.0

type GenresIndex []GenreFreq

func (GenresIndex) Len added in v1.13.0

func (g GenresIndex) Len() int

func (GenresIndex) Less added in v1.13.0

func (g GenresIndex) Less(i, j int) bool

func (GenresIndex) Swap added in v1.13.0

func (g GenresIndex) Swap(i, j int)

type IBooksInfoRepo added in v1.12.0

type IBooksInfoRepo interface {
	io.Closer
	GetItems(query.Query, pagination.IPager, []search.SearchSort, *bleve.HighlightRequest, ...string) ([]BookInfo, error)
	FindByID(string) (BookInfo, error)
	FindBooks(queryStr, tagName, tagValue string, pager pagination.IPager) ([]BookInfo, error)
	SaveBook(BookInfo) error
	GetGenres(pagination.IPager) (GenresIndex, error)
	Remove(string) error
	GetSeriesBooks(string, *BookInfo) ([]BookInfo, error)
	GetOtherAuthorBooks(string, *BookInfo) ([]BookInfo, error)
	GetOtherAuthorSeries(authors, curSeries string) (map[string]int, error)
	GetStats() (map[string]uint64, error)
	GetSeriesByLetter(string) ([]string, error)
	GetAuthorsByLetter(string) ([]string, error)
}

type IBooksLibraryRepo added in v1.12.0

type IBooksLibraryRepo interface {
	GetFB2(BookInfo) (fb2parse.FB2File, error)
}

type ILibMarksRepo added in v1.12.0

type ILibMarksRepo interface {
	MarkExists(string) bool
	AddMark(string) error
}

type IMarshal added in v1.12.0

type IMarshal func(any) ([]byte, error)

type ISearchIndex

type ISearchIndex interface {
	io.Closer
	DocCount() (uint64, error)
	Search(req *bleve.SearchRequest) (*bleve.SearchResult, error)
	Index(id string, data interface{}) error
	Name() string
	NewBatch() *bleve.Batch
	Batch(b *bleve.Batch) error
	Delete(string) error
}

type IUnmarshal added in v1.12.0

type IUnmarshal func([]byte, any) error

type LibEncodeType added in v1.12.0

type LibEncodeType string
const (
	LibEncodeMarshaler LibEncodeType = "marshaler"
	LibEncodeParser    LibEncodeType = "parser"
)

type LibItem added in v1.13.0

type LibItem struct {
	Item string
	Lib  string
}

type Libraries added in v1.12.0

type Libraries map[string]Library

func NewLibraries added in v1.12.0

func NewLibraries(cfgKey string, cfg *viper.Viper) (Libraries, error)

func (*Libraries) GetItems added in v1.12.0

func (l *Libraries) GetItems() (res []LibItem, err error)

func (*Libraries) GetSize added in v1.12.0

func (l *Libraries) GetSize() (res int64)

type Library added in v1.12.0

type Library struct {
	Disabled bool   `mapstructure:"disabled"`
	Dir      string `mapstructure:"dir"`
	Name     string
	Order    int           `mapstructure:"order"`
	Types    []string      `mapstructure:"types"`
	Encoder  LibEncodeType `mapstructure:"encoder"`
}

func (*Library) GetItems added in v1.12.0

func (l *Library) GetItems() (res []string, err error)

func (*Library) GetSize added in v1.12.0

func (l *Library) GetSize() int64

Jump to

Keyboard shortcuts

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