Organize backend into product executable and shared Go modules

This commit is contained in:
Stephan D committed 2026-09-12 14:14:08 +02:00
1 parent 981e84a4b4
commit f0720ec66b
382 files changed
+1944 -6989

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
package mutil
import (
"context"
"git.sendico.io/tech/sxchnge/shared/database/record"
"git.sendico.io/tech/sxchnge/shared/database/repository"
"git.sendico.io/tech/sxchnge/shared/logging"
"git.sendico.io/tech/sxchnge/shared/logging/fields"
"go.mongodb.org/mongo-driver/v2/bson"
"go.uber.org/zap"
)
func SetArchived[T storable.Storable](ctx context.Context, logger mlogger.Logger, newArchived bool, objectRef bson.ObjectID, repo repository.Repository) error {
objs, err := GetObjects[T](ctx, logger, repository.IDFilter(objectRef), nil, repo)
if err != nil {
logger.Warn("Failed to fetch object", zap.Error(err), mzap.ObjRef("object_ref", objectRef))
return err
}
if len(objs) == 0 {
logger.Warn("No objects found to archive", mzap.ObjRef("object_ref", objectRef))
return nil
}
// Archive the first object found
obj := objs[0]
if archivable, ok := any(obj).(interface{ SetArchived(bool) }); ok {
archivable.SetArchived(newArchived)
if err := repo.Update(ctx, obj); err != nil {
logger.Warn("Failed to update object archived status", zap.Error(err), mzap.ObjRef("object_ref", objectRef))
return err
}
}
return nil
}