entities

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

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"`
	Titles    string `json:"name"`
	Authors   string `json:"auth"`
	Sequences string `json:"seq"`
	Date      string `json:"date"`
	Genres    string `json:"genr"`
	Publisher string `json:"publ"`
	Lang      string `json:"lng"`
}

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 IBooksInfoRepo added in v1.12.0

type IBooksInfoRepo interface {
	io.Closer
	SearchAll(string, pagination.IPager) ([]BookInfo, error)
	SearchByAuthor(string, pagination.IPager) ([]BookInfo, error)
	SearchBySequence(string, pagination.IPager) ([]BookInfo, error)
	GetBook(string) (BookInfo, error)
	SaveBook(BookInfo) 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
}

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 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() (map[string]string, 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
	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