art

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: MIT Imports: 12 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 Service

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

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) StoreStatics

func (s *Service) StoreStatics(statics ...*VariantContent) error

func (*Service) TakeStatics

func (s *Service) TakeStatics(statics ...*VariantContent) 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,omitempty"`
	ContentPath    string `gorm:"" json:"contentPath,omitempty"`
	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

func (*Variant) ToStatic

func (v *Variant) ToStatic() *VariantContent

type VariantContent

type VariantContent struct {
	ArtID     string `params:"id"`
	Variation string `params:"variation"`
	Content   []byte
}

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

func (*VariantContent) Check

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

func (*VariantContent) Path

func (s *VariantContent) Path(root string) string

func (*VariantContent) PathRel

func (s *VariantContent) PathRel() string

func (*VariantContent) String

func (s *VariantContent) String() string

Jump to

Keyboard shortcuts

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