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:
@@ -3,7 +3,6 @@ package gallery
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
@@ -15,9 +14,8 @@ type ImageUpdater interface {
|
||||
}
|
||||
|
||||
func (s *Service) Updated(ctx context.Context, galleryID int) error {
|
||||
_, err := s.Repository.UpdatePartial(ctx, galleryID, models.GalleryPartial{
|
||||
UpdatedAt: models.NewOptionalTime(time.Now()),
|
||||
})
|
||||
galleryPartial := models.NewGalleryPartial()
|
||||
_, err := s.Repository.UpdatePartial(ctx, galleryID, galleryPartial)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -55,21 +53,21 @@ func (s *Service) RemoveImages(ctx context.Context, g *models.Gallery, toRemove
|
||||
}
|
||||
|
||||
func AddPerformer(ctx context.Context, qb models.GalleryUpdater, o *models.Gallery, performerID int) error {
|
||||
_, err := qb.UpdatePartial(ctx, o.ID, models.GalleryPartial{
|
||||
PerformerIDs: &models.UpdateIDs{
|
||||
IDs: []int{performerID},
|
||||
Mode: models.RelationshipUpdateModeAdd,
|
||||
},
|
||||
})
|
||||
galleryPartial := models.NewGalleryPartial()
|
||||
galleryPartial.PerformerIDs = &models.UpdateIDs{
|
||||
IDs: []int{performerID},
|
||||
Mode: models.RelationshipUpdateModeAdd,
|
||||
}
|
||||
_, err := qb.UpdatePartial(ctx, o.ID, galleryPartial)
|
||||
return err
|
||||
}
|
||||
|
||||
func AddTag(ctx context.Context, qb models.GalleryUpdater, o *models.Gallery, tagID int) error {
|
||||
_, err := qb.UpdatePartial(ctx, o.ID, models.GalleryPartial{
|
||||
TagIDs: &models.UpdateIDs{
|
||||
IDs: []int{tagID},
|
||||
Mode: models.RelationshipUpdateModeAdd,
|
||||
},
|
||||
})
|
||||
galleryPartial := models.NewGalleryPartial()
|
||||
galleryPartial.TagIDs = &models.UpdateIDs{
|
||||
IDs: []int{tagID},
|
||||
Mode: models.RelationshipUpdateModeAdd,
|
||||
}
|
||||
_, err := qb.UpdatePartial(ctx, o.ID, galleryPartial)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user