mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Model refactor, part 2 (#4092)
* Move conversions into changesetTranslator * Improve mutation error messages * Use models.New and models.NewPartial everywhere * Replace getStashIDsFor functions * Remove ImageCreateInput * Remove unused parameters * Refactor matching functions --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,38 @@ type Studio struct {
|
||||
StashIDs RelatedStashIDs `json:"stash_ids"`
|
||||
}
|
||||
|
||||
func NewStudio() Studio {
|
||||
currentTime := time.Now()
|
||||
return Studio{
|
||||
CreatedAt: currentTime,
|
||||
UpdatedAt: currentTime,
|
||||
}
|
||||
}
|
||||
|
||||
// StudioPartial represents part of a Studio object. It is used to update the database entry.
|
||||
type StudioPartial struct {
|
||||
ID int
|
||||
Name OptionalString
|
||||
URL OptionalString
|
||||
ParentID OptionalInt
|
||||
// Rating expressed in 1-100 scale
|
||||
Rating OptionalInt
|
||||
Details OptionalString
|
||||
CreatedAt OptionalTime
|
||||
UpdatedAt OptionalTime
|
||||
IgnoreAutoTag OptionalBool
|
||||
|
||||
Aliases *UpdateStrings
|
||||
StashIDs *UpdateStashIDs
|
||||
}
|
||||
|
||||
func NewStudioPartial() StudioPartial {
|
||||
currentTime := time.Now()
|
||||
return StudioPartial{
|
||||
UpdatedAt: NewOptionalTime(currentTime),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Studio) LoadAliases(ctx context.Context, l AliasLoader) error {
|
||||
return s.Aliases.load(func() ([]string, error) {
|
||||
return l.GetAliases(ctx, s.ID)
|
||||
@@ -44,30 +76,3 @@ func (s *Studio) LoadRelationships(ctx context.Context, l PerformerReader) error
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// StudioPartial represents part of a Studio object. It is used to update the database entry.
|
||||
type StudioPartial struct {
|
||||
ID int
|
||||
Name OptionalString
|
||||
URL OptionalString
|
||||
ParentID OptionalInt
|
||||
// Rating expressed in 1-100 scale
|
||||
Rating OptionalInt
|
||||
Details OptionalString
|
||||
CreatedAt OptionalTime
|
||||
UpdatedAt OptionalTime
|
||||
IgnoreAutoTag OptionalBool
|
||||
|
||||
Aliases *UpdateStrings
|
||||
StashIDs *UpdateStashIDs
|
||||
}
|
||||
|
||||
type Studios []*Studio
|
||||
|
||||
func (s *Studios) Append(o interface{}) {
|
||||
*s = append(*s, o.(*Studio))
|
||||
}
|
||||
|
||||
func (s *Studios) New() interface{} {
|
||||
return &Studio{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user