mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Model refactor (#3915)
* Add mockery config file * Move basic file/folder structs to models * Fix hack due to import loop * Move file interfaces to models * Move folder interfaces to models * Move scene interfaces to models * Move scene marker interfaces to models * Move image interfaces to models * Move gallery interfaces to models * Move gallery chapter interfaces to models * Move studio interfaces to models * Move movie interfaces to models * Move performer interfaces to models * Move tag interfaces to models * Move autotag interfaces to models * Regenerate mocks
This commit is contained in:
94
pkg/models/repository_studio.go
Normal file
94
pkg/models/repository_studio.go
Normal file
@@ -0,0 +1,94 @@
|
||||
package models
|
||||
|
||||
import "context"
|
||||
|
||||
// StudioGetter provides methods to get studios by ID.
|
||||
type StudioGetter interface {
|
||||
// TODO - rename this to Find and remove existing method
|
||||
FindMany(ctx context.Context, ids []int) ([]*Studio, error)
|
||||
Find(ctx context.Context, id int) (*Studio, error)
|
||||
}
|
||||
|
||||
// StudioFinder provides methods to find studios.
|
||||
type StudioFinder interface {
|
||||
StudioGetter
|
||||
FindChildren(ctx context.Context, id int) ([]*Studio, error)
|
||||
FindBySceneID(ctx context.Context, sceneID int) (*Studio, error)
|
||||
FindByStashID(ctx context.Context, stashID StashID) ([]*Studio, error)
|
||||
FindByStashIDStatus(ctx context.Context, hasStashID bool, stashboxEndpoint string) ([]*Studio, error)
|
||||
FindByName(ctx context.Context, name string, nocase bool) (*Studio, error)
|
||||
}
|
||||
|
||||
// StudioQueryer provides methods to query studios.
|
||||
type StudioQueryer interface {
|
||||
Query(ctx context.Context, studioFilter *StudioFilterType, findFilter *FindFilterType) ([]*Studio, int, error)
|
||||
}
|
||||
|
||||
type StudioAutoTagQueryer interface {
|
||||
StudioQueryer
|
||||
AliasLoader
|
||||
|
||||
// TODO - this interface is temporary until the filter schema can fully
|
||||
// support the query needed
|
||||
QueryForAutoTag(ctx context.Context, words []string) ([]*Studio, error)
|
||||
}
|
||||
|
||||
// StudioCounter provides methods to count studios.
|
||||
type StudioCounter interface {
|
||||
Count(ctx context.Context) (int, error)
|
||||
}
|
||||
|
||||
// StudioCreator provides methods to create studios.
|
||||
type StudioCreator interface {
|
||||
Create(ctx context.Context, newStudio *Studio) error
|
||||
}
|
||||
|
||||
// StudioUpdater provides methods to update studios.
|
||||
type StudioUpdater interface {
|
||||
Update(ctx context.Context, updatedStudio *Studio) error
|
||||
UpdatePartial(ctx context.Context, updatedStudio StudioPartial) (*Studio, error)
|
||||
UpdateImage(ctx context.Context, studioID int, image []byte) error
|
||||
}
|
||||
|
||||
// StudioDestroyer provides methods to destroy studios.
|
||||
type StudioDestroyer interface {
|
||||
Destroy(ctx context.Context, id int) error
|
||||
}
|
||||
|
||||
type StudioFinderCreator interface {
|
||||
StudioFinder
|
||||
StudioCreator
|
||||
}
|
||||
|
||||
type StudioCreatorUpdater interface {
|
||||
StudioCreator
|
||||
StudioUpdater
|
||||
}
|
||||
|
||||
// StudioReader provides all methods to read studios.
|
||||
type StudioReader interface {
|
||||
StudioFinder
|
||||
StudioQueryer
|
||||
StudioAutoTagQueryer
|
||||
StudioCounter
|
||||
|
||||
AliasLoader
|
||||
StashIDLoader
|
||||
|
||||
All(ctx context.Context) ([]*Studio, error)
|
||||
GetImage(ctx context.Context, studioID int) ([]byte, error)
|
||||
HasImage(ctx context.Context, studioID int) (bool, error)
|
||||
}
|
||||
|
||||
// StudioWriter provides all methods to modify studios.
|
||||
type StudioWriter interface {
|
||||
StudioCreator
|
||||
StudioUpdater
|
||||
StudioDestroyer
|
||||
}
|
||||
|
||||
// StudioReaderWriter provides all studio methods.
|
||||
type StudioReaderWriter interface {
|
||||
StudioReader
|
||||
StudioWriter
|
||||
}
|
||||
Reference in New Issue
Block a user