art

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package art provides functionalities related to Art and Variant of the game, including serving them, manipulating them and keep them persisted.

This package exposes its main interfaces by fx via FxModule function. However, it is still easy to instantiate an art.Service by simply creating it.

Index

Constants

View Source
const (
	CategoryImage      string = "image"
	CategoryBackground string = "background"
	CategoryItem       string = "item"
	CategoryCharacter  string = "character"
)
View Source
const (
	VariationOrigin     string = "origin"
	VariationThumbnail  string = "thumbnail"
	VariationRealEsrgan string = "real-esrgan"
)

Variables

View Source
var (
	ErrNotFound = errors.New("the resource with the identifier(s) is not found")
)

Functions

func FxModule

func FxModule() fx.Option

FxModule teaches a fx.App how to instantiate an art.Service, and also optionally register its HTTP endpoints on api.V1 if provided.

Types

type Art

type Art struct {
	ID       string `gorm:"primaryKey;type:text COLLATE numeric" json:"id" validate:""`
	Category string `gorm:"" json:"category" validate:"oneof=image background item character"`

	Variants []Variant `gorm:"" json:"variants,omitempty" validate:""`
}

func NewArt

func NewArt(id string, category string) *Art

type Content added in v1.0.7

type Content struct {
	ID        string
	Category  string
	Variation string
	Content   []byte
}

Content helps store and take the content of a variant to or from the filesystem.

func (*Content) Check added in v1.0.7

func (s *Content) Check() (*image.Config, error)

func (*Content) PathRel added in v1.0.7

func (s *Content) PathRel() string

func (*Content) String added in v1.0.7

func (s *Content) String() string

type ContentParams added in v1.0.7

type ContentParams struct {
	ID        string `param:"id"`
	Variation string `param:"variation"`
}

type Service

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

func (*Service) Authenticate added in v1.1.0

func (s *Service) Authenticate(uuid uuid.UUID) *infra.User

func (*Service) SelectArt

func (s *Service) SelectArt(id string) (*Art, error)

func (*Service) SelectArts

func (s *Service) SelectArts(category *string) ([]*Art, error)

func (*Service) SelectArtsWhoseVariantAbsent

func (s *Service) SelectArtsWhoseVariantAbsent(variation string) ([]*Art, error)

func (*Service) SelectVariant

func (s *Service) SelectVariant(id string, kind string) (*Variant, error)

func (*Service) SelectVariants

func (s *Service) SelectVariants(id string) ([]*Variant, error)

func (*Service) StoreContent added in v1.0.7

func (s *Service) StoreContent(id string, variation string, content []byte) (err error)

func (*Service) TakeContent added in v1.0.7

func (s *Service) TakeContent(id string, variation string) (content []byte, err error)

func (*Service) UpsertArts

func (s *Service) UpsertArts(arts ...*Art) error

func (*Service) UpsertVariants

func (s *Service) UpsertVariants(variants ...*Variant) error

type Variant

type Variant struct {
	ArtID     string `gorm:"primaryKey;type:text COLLATE numeric" json:"artID"`
	Variation string `gorm:"primaryKey" json:"variation,omitempty"`

	ContentPresent bool `gorm:"" json:"contentPresent"`
	ContentWidth   *int `gorm:"" json:"contentWidth,omitempty"`
	ContentHeight  *int `gorm:"" json:"contentHeight,omitempty"`
}

func NewVariant

func NewVariant(id string, variation string) *Variant

func (*Variant) String

func (v *Variant) String() string

Jump to

Keyboard shortcuts

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