mirror of https://github.com/stashapp/stash.git
237 lines
7.5 KiB
Go
237 lines
7.5 KiB
Go
package models
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"strconv"
|
|
)
|
|
|
|
type GenderEnum string
|
|
|
|
const (
|
|
GenderEnumMale GenderEnum = "MALE"
|
|
GenderEnumFemale GenderEnum = "FEMALE"
|
|
GenderEnumTransgenderMale GenderEnum = "TRANSGENDER_MALE"
|
|
GenderEnumTransgenderFemale GenderEnum = "TRANSGENDER_FEMALE"
|
|
GenderEnumIntersex GenderEnum = "INTERSEX"
|
|
GenderEnumNonBinary GenderEnum = "NON_BINARY"
|
|
)
|
|
|
|
var AllGenderEnum = []GenderEnum{
|
|
GenderEnumMale,
|
|
GenderEnumFemale,
|
|
GenderEnumTransgenderMale,
|
|
GenderEnumTransgenderFemale,
|
|
GenderEnumIntersex,
|
|
GenderEnumNonBinary,
|
|
}
|
|
|
|
func (e GenderEnum) IsValid() bool {
|
|
switch e {
|
|
case GenderEnumMale, GenderEnumFemale, GenderEnumTransgenderMale, GenderEnumTransgenderFemale, GenderEnumIntersex, GenderEnumNonBinary:
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (e GenderEnum) String() string {
|
|
return string(e)
|
|
}
|
|
|
|
func (e *GenderEnum) UnmarshalGQL(v interface{}) error {
|
|
str, ok := v.(string)
|
|
if !ok {
|
|
return fmt.Errorf("enums must be strings")
|
|
}
|
|
|
|
*e = GenderEnum(str)
|
|
if !e.IsValid() {
|
|
return fmt.Errorf("%s is not a valid GenderEnum", str)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (e GenderEnum) MarshalGQL(w io.Writer) {
|
|
fmt.Fprint(w, strconv.Quote(e.String()))
|
|
}
|
|
|
|
type GenderCriterionInput struct {
|
|
Value *GenderEnum `json:"value"`
|
|
Modifier CriterionModifier `json:"modifier"`
|
|
}
|
|
|
|
type CircumisedEnum string
|
|
|
|
const (
|
|
CircumisedEnumCut CircumisedEnum = "CUT"
|
|
CircumisedEnumUncut CircumisedEnum = "UNCUT"
|
|
)
|
|
|
|
var AllCircumcisionEnum = []CircumisedEnum{
|
|
CircumisedEnumCut,
|
|
CircumisedEnumUncut,
|
|
}
|
|
|
|
func (e CircumisedEnum) IsValid() bool {
|
|
switch e {
|
|
case CircumisedEnumCut, CircumisedEnumUncut:
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (e CircumisedEnum) String() string {
|
|
return string(e)
|
|
}
|
|
|
|
func (e *CircumisedEnum) UnmarshalGQL(v interface{}) error {
|
|
str, ok := v.(string)
|
|
if !ok {
|
|
return fmt.Errorf("enums must be strings")
|
|
}
|
|
|
|
*e = CircumisedEnum(str)
|
|
if !e.IsValid() {
|
|
return fmt.Errorf("%s is not a valid CircumisedEnum", str)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (e CircumisedEnum) MarshalGQL(w io.Writer) {
|
|
fmt.Fprint(w, strconv.Quote(e.String()))
|
|
}
|
|
|
|
type CircumcisionCriterionInput struct {
|
|
Value []CircumisedEnum `json:"value"`
|
|
Modifier CriterionModifier `json:"modifier"`
|
|
}
|
|
|
|
type PerformerFilterType struct {
|
|
And *PerformerFilterType `json:"AND"`
|
|
Or *PerformerFilterType `json:"OR"`
|
|
Not *PerformerFilterType `json:"NOT"`
|
|
Name *StringCriterionInput `json:"name"`
|
|
Disambiguation *StringCriterionInput `json:"disambiguation"`
|
|
Details *StringCriterionInput `json:"details"`
|
|
// Filter by favorite
|
|
FilterFavorites *bool `json:"filter_favorites"`
|
|
// Filter by birth year
|
|
BirthYear *IntCriterionInput `json:"birth_year"`
|
|
// Filter by age
|
|
Age *IntCriterionInput `json:"age"`
|
|
// Filter by ethnicity
|
|
Ethnicity *StringCriterionInput `json:"ethnicity"`
|
|
// Filter by country
|
|
Country *StringCriterionInput `json:"country"`
|
|
// Filter by eye color
|
|
EyeColor *StringCriterionInput `json:"eye_color"`
|
|
// Filter by height - deprecated: use height_cm instead
|
|
Height *StringCriterionInput `json:"height"`
|
|
// Filter by height in centimeters
|
|
HeightCm *IntCriterionInput `json:"height_cm"`
|
|
// Filter by measurements
|
|
Measurements *StringCriterionInput `json:"measurements"`
|
|
// Filter by fake tits value
|
|
FakeTits *StringCriterionInput `json:"fake_tits"`
|
|
// Filter by penis length value
|
|
PenisLength *FloatCriterionInput `json:"penis_length"`
|
|
// Filter by circumcision
|
|
Circumcised *CircumcisionCriterionInput `json:"circumcised"`
|
|
// Filter by career length
|
|
CareerLength *StringCriterionInput `json:"career_length"`
|
|
// Filter by tattoos
|
|
Tattoos *StringCriterionInput `json:"tattoos"`
|
|
// Filter by piercings
|
|
Piercings *StringCriterionInput `json:"piercings"`
|
|
// Filter by aliases
|
|
Aliases *StringCriterionInput `json:"aliases"`
|
|
// Filter by gender
|
|
Gender *GenderCriterionInput `json:"gender"`
|
|
// Filter to only include performers missing this property
|
|
IsMissing *string `json:"is_missing"`
|
|
// Filter to only include performers with these tags
|
|
Tags *HierarchicalMultiCriterionInput `json:"tags"`
|
|
// Filter by tag count
|
|
TagCount *IntCriterionInput `json:"tag_count"`
|
|
// Filter by scene count
|
|
SceneCount *IntCriterionInput `json:"scene_count"`
|
|
// Filter by image count
|
|
ImageCount *IntCriterionInput `json:"image_count"`
|
|
// Filter by gallery count
|
|
GalleryCount *IntCriterionInput `json:"gallery_count"`
|
|
// Filter by O count
|
|
OCounter *IntCriterionInput `json:"o_counter"`
|
|
// Filter by StashID
|
|
StashID *StringCriterionInput `json:"stash_id"`
|
|
// Filter by StashID Endpoint
|
|
StashIDEndpoint *StashIDCriterionInput `json:"stash_id_endpoint"`
|
|
// Filter by rating expressed as 1-5
|
|
Rating *IntCriterionInput `json:"rating"`
|
|
// Filter by rating expressed as 1-100
|
|
Rating100 *IntCriterionInput `json:"rating100"`
|
|
// Filter by url
|
|
URL *StringCriterionInput `json:"url"`
|
|
// Filter by hair color
|
|
HairColor *StringCriterionInput `json:"hair_color"`
|
|
// Filter by weight
|
|
Weight *IntCriterionInput `json:"weight"`
|
|
// Filter by death year
|
|
DeathYear *IntCriterionInput `json:"death_year"`
|
|
// Filter by studios where performer appears in scene/image/gallery
|
|
Studios *HierarchicalMultiCriterionInput `json:"studios"`
|
|
// Filter by performers where performer appears with another performer in scene/image/gallery
|
|
Performers *MultiCriterionInput `json:"performers"`
|
|
// Filter by autotag ignore value
|
|
IgnoreAutoTag *bool `json:"ignore_auto_tag"`
|
|
// Filter by birthdate
|
|
Birthdate *DateCriterionInput `json:"birth_date"`
|
|
// Filter by death date
|
|
DeathDate *DateCriterionInput `json:"death_date"`
|
|
// Filter by created at
|
|
CreatedAt *TimestampCriterionInput `json:"created_at"`
|
|
// Filter by updated at
|
|
UpdatedAt *TimestampCriterionInput `json:"updated_at"`
|
|
}
|
|
|
|
type PerformerFinder interface {
|
|
FindMany(ctx context.Context, ids []int) ([]*Performer, error)
|
|
}
|
|
|
|
type PerformerReader interface {
|
|
Find(ctx context.Context, id int) (*Performer, error)
|
|
PerformerFinder
|
|
FindBySceneID(ctx context.Context, sceneID int) ([]*Performer, error)
|
|
FindByImageID(ctx context.Context, imageID int) ([]*Performer, error)
|
|
FindByGalleryID(ctx context.Context, galleryID int) ([]*Performer, error)
|
|
FindByNames(ctx context.Context, names []string, nocase bool) ([]*Performer, error)
|
|
FindByStashID(ctx context.Context, stashID StashID) ([]*Performer, error)
|
|
FindByStashIDStatus(ctx context.Context, hasStashID bool, stashboxEndpoint string) ([]*Performer, error)
|
|
CountByTagID(ctx context.Context, tagID int) (int, error)
|
|
Count(ctx context.Context) (int, error)
|
|
All(ctx context.Context) ([]*Performer, error)
|
|
// TODO - this interface is temporary until the filter schema can fully
|
|
// support the query needed
|
|
QueryForAutoTag(ctx context.Context, words []string) ([]*Performer, error)
|
|
Query(ctx context.Context, performerFilter *PerformerFilterType, findFilter *FindFilterType) ([]*Performer, int, error)
|
|
QueryCount(ctx context.Context, galleryFilter *PerformerFilterType, findFilter *FindFilterType) (int, error)
|
|
AliasLoader
|
|
GetImage(ctx context.Context, performerID int) ([]byte, error)
|
|
HasImage(ctx context.Context, performerID int) (bool, error)
|
|
StashIDLoader
|
|
TagIDLoader
|
|
}
|
|
|
|
type PerformerWriter interface {
|
|
Create(ctx context.Context, newPerformer *Performer) error
|
|
UpdatePartial(ctx context.Context, id int, updatedPerformer PerformerPartial) (*Performer, error)
|
|
Update(ctx context.Context, updatedPerformer *Performer) error
|
|
Destroy(ctx context.Context, id int) error
|
|
UpdateImage(ctx context.Context, performerID int, image []byte) error
|
|
}
|
|
|
|
type PerformerReaderWriter interface {
|
|
PerformerReader
|
|
PerformerWriter
|
|
}
|