Initial commit: Open sourcing all of the Maple Open Technologies code.
This commit is contained in:
commit
755d54a99d
2010 changed files with 448675 additions and 0 deletions
34
cloud/maplefile-backend/internal/repo/collection/archive.go
Normal file
34
cloud/maplefile-backend/internal/repo/collection/archive.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
// monorepo/cloud/maplefile-backend/internal/maplefile/repo/collection/archive.go
|
||||
package collection
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gocql/gocql"
|
||||
dom_collection "codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/internal/domain/collection"
|
||||
)
|
||||
|
||||
func (impl *collectionRepositoryImpl) Archive(ctx context.Context, id gocql.UUID) error {
|
||||
collection, err := impl.Get(ctx, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get collection for archive: %w", err)
|
||||
}
|
||||
|
||||
if collection == nil {
|
||||
return fmt.Errorf("collection not found")
|
||||
}
|
||||
|
||||
// Validate state transition
|
||||
if err := dom_collection.IsValidStateTransition(collection.State, dom_collection.CollectionStateArchived); err != nil {
|
||||
return fmt.Errorf("invalid state transition: %w", err)
|
||||
}
|
||||
|
||||
// Update collection state
|
||||
collection.State = dom_collection.CollectionStateArchived
|
||||
collection.ModifiedAt = time.Now()
|
||||
collection.Version++
|
||||
|
||||
return impl.Update(ctx, collection)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue