mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
* Add UI support for setting containing groups * Show containing groups in group details panel * Move tag hierarchical filter code into separate type * Add depth to scene_count and add sub_group_count * Add sub-groups tab to groups page * Add containing groups to edit groups dialog * Show containing group description in sub-group view * Show group scene number in group scenes view * Add ability to drag move grid cards * Add sub group order option * Add reorder sub-groups interface * Separate page size selector component * Add interfaces to add and remove sub-groups to a group * Separate MultiSet components * Allow setting description while setting containing groups
41 lines
803 B
Go
41 lines
803 B
Go
package group
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
)
|
|
|
|
var (
|
|
ErrEmptyName = errors.New("name cannot be empty")
|
|
ErrHierarchyLoop = errors.New("a group cannot be contained by one of its subgroups")
|
|
)
|
|
|
|
func (s *Service) Create(ctx context.Context, group *models.Group, frontimageData []byte, backimageData []byte) error {
|
|
r := s.Repository
|
|
|
|
if err := s.validateCreate(ctx, group); err != nil {
|
|
return err
|
|
}
|
|
|
|
err := r.Create(ctx, group)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// update image table
|
|
if len(frontimageData) > 0 {
|
|
if err := r.UpdateFrontImage(ctx, group.ID, frontimageData); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
if len(backimageData) > 0 {
|
|
if err := r.UpdateBackImage(ctx, group.ID, backimageData); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|