model

package
v0.0.0-...-4cc3681 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidInput  = errors.New("invalid input")
	ErrInternalError = errors.New("server or network error")
)

Functions

This section is empty.

Types

type EntityList

type EntityList struct {
	*Page
	Type        EntityType
	IsSearch    bool
	Keyword     string
	TotalCount  int64
	PageCount   int64
	PageTotal   int64
	PageCurrent int64
	PageNext    *Pagination
	PagePrev    *Pagination
	Filter      Filter
	List        interface{}
}

func (*EntityList) GetPagination

func (l *EntityList) GetPagination() error

type EntityPage

type EntityPage struct {
	*Page
	Entity interface{}
}

type EntityType

type EntityType int
const (
	TypeItem EntityType = iota
	TypeLocation
	TypeMixed
)

func (EntityType) String

func (et EntityType) String() string

type Filter

type Filter interface {
	GetAll() map[string][]string
	Get(string) []string
}

type IndexPage

type IndexPage struct {
	*Page
}

type Page

type Page struct {
	App  *version.Application
	API  *api.API
	Host string
	Path string
	URI  string
}

func CreatePage

func CreatePage(u *url.URL) *Page

func CreatePageWithAPI

func CreatePageWithAPI(u *url.URL) (*Page, error)

func (*Page) Entity

func (p *Page) Entity(e interface{}) *EntityPage

func (*Page) GetIndex

func (p *Page) GetIndex() *IndexPage

func (*Page) Result

func (p *Page) Result(res interface{}, kw string) (*EntityList, error)

type Pagination

type Pagination struct {
	Number int64
	URL    string
}

type Response

type Response struct {
	Status     string `json:"status"`
	Message    string `json:"message"`
	StatusCode int    `json:"code"`
}

Response describes a JSON status response

func NewResponse

func NewResponse(msg string, code int) *Response

NewResponse creates a new JSON status response based on parameters

type SearchFilter

type SearchFilter struct {
	Category string
	Location string
	ByName   bool
}

type SearchOperation

type SearchOperation struct {
	Term    string
	Filter  *SearchFilter
	Limit   int
	Results chan []*SearchResult
	Error   error
	Tasks   sync.WaitGroup
	sync.RWMutex
}

func NewSearch

func NewSearch(term string, filter *SearchFilter, limit int) *SearchOperation

func (*SearchOperation) Close

func (so *SearchOperation) Close()

func (*SearchOperation) Items

func (so *SearchOperation) Items()

func (*SearchOperation) Locations

func (so *SearchOperation) Locations()

type SearchResult

type SearchResult struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	ShortName string     `json:"shortName,omitempty"`
	Parent    string     `json:"parent,omitempty"`
	Type      EntityType `json:"type"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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