art

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: MIT Imports: 15 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

This section is empty.

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;check:id=lower(id)" json:"id"`
	Category Category `gorm:"type:art_category" json:"category"`

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

func NewArt

func NewArt(id string, category Category) *Art

type Category added in v1.4.0

type Category string
const (
	CategoryImage      Category = "image"
	CategoryBackground Category = "background"
	CategoryItem       Category = "item"
	CategoryCharacter  Category = "character"
)

func MustParseCategory added in v1.4.0

func MustParseCategory(str string) Category

func ParseCategory added in v1.4.0

func ParseCategory(str string) (Category, error)

func (*Category) UnmarshalJSON added in v1.4.0

func (c *Category) UnmarshalJSON(bytes []byte) error

type Content added in v1.0.7

type Content struct {
	ID        string
	Category  Category
	Variation Variation
	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 Variation `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() ([]*Art, error)

func (*Service) SelectArtsByCategory added in v1.4.0

func (s *Service) SelectArtsByCategory(category Category) ([]*Art, error)

func (*Service) SelectArtsByIDs added in v1.2.0

func (s *Service) SelectArtsByIDs(ids []string) ([]*Art, error)

func (*Service) SelectArtsWhoseVariantAbsent

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

func (*Service) SelectVariant

func (s *Service) SelectVariant(id string, variation Variation) (*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 Variation, content []byte) (err error)

func (*Service) TakeContent added in v1.0.7

func (s *Service) TakeContent(id string, variation Variation) (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;check:art_id=lower(art_id)" json:"artID"`
	Variation Variation `gorm:"primaryKey;type:art_variation" 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 Variation) *Variant

func (*Variant) String

func (v *Variant) String() string

type Variation added in v1.4.0

type Variation string
const (
	VariationOrigin                Variation = "origin"
	VariationRealEsrganX4Plus      Variation = "real-esrgan(realesrgan-x4plus)"
	VariationRealEsrganX4PlusAnime Variation = "real-esrgan(realesrgan-x4plus-anime)"
	VariationThumbnail             Variation = "thumbnail"
)

func ParseVariation added in v1.4.0

func ParseVariation(str string) (Variation, error)

func (*Variation) UnmarshalJSON added in v1.4.0

func (v *Variation) UnmarshalJSON(bytes []byte) error

Jump to

Keyboard shortcuts

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