Documentation ¶
Index ¶
- Variables
- func ImagePath(itemID *ID, imageID *uuid.UUID, filename string) string
- func Register(name string, driver Driver)
- func Slugify(str string) string
- func SortBidsByCreatedAtAsc(b1, b2 *Bid) bool
- func SortBidsByCreatedAtDesc(b1, b2 *Bid) bool
- func SortBidsByIDAsc(b1, b2 *Bid) bool
- func SortBidsByIDDesc(b1, b2 *Bid) bool
- func SortItemsByCreatedAtAsc(i1, i2 *Item) bool
- func SortItemsByCreatedAtDesc(i1, i2 *Item) bool
- func SortItemsByIDAsc(i1, i2 *Item) bool
- func SortItemsByIDDesc(i1, i2 *Item) bool
- type Bid
- type BidSorter
- type Bids
- type Currency
- type Driver
- type ID
- type IImage
- type Image
- type Item
- type ItemSorter
- type PaginateOptions
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound not found. ErrNotFound = errors.New("not found") // ErrInvalidInput invalid input. ErrInvalidInput = errors.New("invalid input") // ErrNoResults no results. ErrNoResults = errors.New("no results") // ErrNilPointer nil pointer passed. ErrNilPointer = errors.New("nil pointer passed") )
View Source
var NilID = ID(0)
View Source
var ( // StorageURL default storage engine. StorageURL string )
Functions ¶
func SortBidsByCreatedAtAsc ¶
func SortBidsByCreatedAtDesc ¶
func SortBidsByIDAsc ¶
func SortBidsByIDDesc ¶
func SortItemsByCreatedAtAsc ¶
func SortItemsByIDAsc ¶
func SortItemsByIDDesc ¶
Types ¶
type Bid ¶
type Bid struct { ID ID `json:"id" db:"id"` CreatedAt *time.Time `json:"created_at" db:"created_at"` Value Currency `json:"value" db:"value"` UserID *ID `json:"user_id" db:"user_id"` ItemID *ID `json:"item_id" db:"item_id"` Valid bool `json:"valid" db:"valid"` User *User `json:"-"` Item *Item `json:"-"` }
type BidSorter ¶
type BidSorter struct {
// contains filtered or unexported fields
}
func BidsOrderedBy ¶
func BidsOrderedBy(less ...bidLess) *BidSorter
type Driver ¶
type Driver interface { // Open creates a connection to the driver. Open(url string) (Driver, error) // Close closes the driver connection. Close() error // CreateItem creates a new item. CreateItem(item *Item) error // ItemCount get count of items. ItemCount(addInactive bool) int // GetBySlug returns an item by its unique slug. GetBySlug(slug string) (*Item, error) // ListItems returns a list of items. ListItems(opts *PaginateOptions, addInactive bool) ([]*Item, error) // ItemBids gets a list of bids for an item. ItemBids(itemID *ID, opts *PaginateOptions) ([]*Bid, error) // CoverImage returns the lowest-order image of an item. CoverImage(itemID *ID) ([]*Image, error) // ItemImages returns the images belonging to an item. ItemImages(itemID *ID) ([]*Image, error) // GetByID returns an Item by id. // GetByID(id *uuid.UUID) (*Item, error) // // DeleteItem deletes an Item by ID. // DeleteItem(id *uuid.UUID) error // // // PlaceBid places a bid on item. // PlaceBid(item *Item, bid *Bid) error // // InvalidateBid invalidates a bid. // InvalidateBid(bid *Bid) error // AddImages adds an image to the item. AddImages(item *Item, image ...IImage) error // RemoveImage removes an image to the item. RemoveImage(id uuid.UUID) error }
Driver all storage engines need to implement this interface.
type Image ¶
type Image struct { ID uuid.UUID // Path relative path to asset on fileserver. Path string `json:"path" db:"path"` // AbsPath absolute path to image. AbsPath string `json:"abs_path" db:"abs_path"` // OriginalFilename the image's original filename. OriginalFilename string AltText string CreatedAt *time.Time `json:"created_at" db:"created_at"` UpdatedAt *time.Time `json:"updated_at" db:"updated_at"` ItemID *ID `json:"item_id" db:"item_id"` Order uint8 `json:"order" db:"order"` }
Image retains image properties to save in the filesystem.
type Item ¶
type Item struct { ID ID `json:"id" db:"id"` OwnerID *ID `json:"owner_id" db:"owner_id"` Name string `json:"name" db:"name"` Slug string `json:"slug" db:"slug"` Description string `json:"description" db:"description"` MinBid Currency `json:"min_bid" db:"min_bid"` MaxBid Currency `json:"max_bid" db:"max_bid"` BidInterval *time.Duration `json:"bid_interval" db:"bid_interval"` BidDeadline *time.Time `json:"bid_deadline" db:"bid_deadline"` Bids Bids `json:"bids"` BidsPublic bool `json:"bids_public" db:"bids_public"` CreatedAt *time.Time `json:"created_at" db:"created_at"` UpdatedAt *time.Time `json:"updated_at" db:"updated_at"` PublishedAt *time.Time `json:"published_at" db:"published_at"` Images []*Image `json:"images"` Owner *User `json:"-"` }
Item struct holds an item's data. Note that amounts that refer to currency are unsigned integers * 100 (to retain decimal precision).
func (*Item) HighestBid ¶
MaxBid returns the higuest bid of an Item.
type ItemSorter ¶
type ItemSorter struct {
// contains filtered or unexported fields
}
func ItemsOrderedBy ¶
func ItemsOrderedBy(less ...itemLess) *ItemSorter
func (*ItemSorter) Len ¶
func (is *ItemSorter) Len() int
func (*ItemSorter) Less ¶
func (is *ItemSorter) Less(i, j int) bool
func (*ItemSorter) Sort ¶
func (is *ItemSorter) Sort(items []*Item)
func (*ItemSorter) Swap ¶
func (is *ItemSorter) Swap(i, j int)
type PaginateOptions ¶
Click to show internal directories.
Click to hide internal directories.