Added update to module mappings, updated generated files
This commit is contained in:
@@ -21,6 +21,7 @@ type (
|
||||
Find(ctx context.Context, filter types.ModuleMappingFilter) (types.ModuleMappingSet, types.ModuleMappingFilter, error)
|
||||
FindByID(ctx context.Context, federationModuleID uint64) (*types.ModuleMapping, error)
|
||||
Create(ctx context.Context, new *types.ModuleMapping) (*types.ModuleMapping, error)
|
||||
Update(ctx context.Context, updated *types.ModuleMapping) (*types.ModuleMapping, error)
|
||||
// FindByAny(ctx context.Context, nodeID uint64, identifier interface{}) (*types.ExposedModule, error)
|
||||
// DeleteByID(ctx context.Context, federationModuleID uint64) error
|
||||
}
|
||||
@@ -132,6 +133,35 @@ func (svc moduleMapping) Create(ctx context.Context, new *types.ModuleMapping) (
|
||||
return new, svc.recordAction(ctx, aProps, ModuleMappingActionCreate, err)
|
||||
}
|
||||
|
||||
func (svc moduleMapping) Update(ctx context.Context, updated *types.ModuleMapping) (*types.ModuleMapping, error) {
|
||||
var (
|
||||
aProps = &moduleMappingActionProps{changed: updated}
|
||||
)
|
||||
|
||||
err := store.Tx(ctx, svc.store, func(ctx context.Context, s store.Storer) (err error) {
|
||||
// TODO
|
||||
// if !svc.ac.CanCreateFederationExposedModule(ctx, ns) {
|
||||
// return ExposedModuleErrNotAllowedToCreate()
|
||||
// }
|
||||
|
||||
if _, err := svc.namespace.With(ctx).FindByID(updated.ComposeNamespaceID); err != nil {
|
||||
return ModuleMappingErrComposeNamespaceNotFound()
|
||||
}
|
||||
|
||||
if _, err := svc.module.With(ctx).FindByID(updated.ComposeNamespaceID, updated.ComposeModuleID); err != nil {
|
||||
return ModuleMappingErrComposeModuleNotFound()
|
||||
}
|
||||
|
||||
if err = store.UpdateFederationModuleMapping(ctx, s, updated); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return updated, svc.recordAction(ctx, aProps, ModuleMappingActionUpdate, err)
|
||||
}
|
||||
|
||||
func (svc moduleMapping) uniqueCheck(ctx context.Context, m *types.ModuleMapping) (err error) {
|
||||
f := types.ModuleMappingFilter{
|
||||
FederationModuleID: m.FederationModuleID,
|
||||
|
||||
@@ -43,9 +43,12 @@ func (s Store) SearchFederationModuleMappings(ctx context.Context, f types.Modul
|
||||
// This tells us to flip the descending flag on all used sort keys
|
||||
reversedCursor := f.PageCursor != nil && f.PageCursor.Reverse
|
||||
|
||||
// Sorting and paging are both enabled in definition yaml file
|
||||
// {search: {enableSorting:true, enablePaging:true}}
|
||||
curSort := f.Sort.Clone()
|
||||
|
||||
// If paging with reverse cursor, change the sorting
|
||||
// direction for all columns we're sorting by
|
||||
curSort := f.Sort.Clone()
|
||||
if reversedCursor {
|
||||
curSort.Reverse()
|
||||
}
|
||||
|
||||
@@ -43,9 +43,12 @@ func (s Store) SearchFederationNodesSyncs(ctx context.Context, f types.NodeSyncF
|
||||
// This tells us to flip the descending flag on all used sort keys
|
||||
reversedCursor := f.PageCursor != nil && f.PageCursor.Reverse
|
||||
|
||||
// Sorting and paging are both enabled in definition yaml file
|
||||
// {search: {enableSorting:true, enablePaging:true}}
|
||||
curSort := f.Sort.Clone()
|
||||
|
||||
// If paging with reverse cursor, change the sorting
|
||||
// direction for all columns we're sorting by
|
||||
curSort := f.Sort.Clone()
|
||||
if reversedCursor {
|
||||
curSort.Reverse()
|
||||
}
|
||||
|
||||
@@ -43,9 +43,12 @@ func (s Store) SearchFederationSharedModules(ctx context.Context, f types.Shared
|
||||
// This tells us to flip the descending flag on all used sort keys
|
||||
reversedCursor := f.PageCursor != nil && f.PageCursor.Reverse
|
||||
|
||||
// Sorting and paging are both enabled in definition yaml file
|
||||
// {search: {enableSorting:true, enablePaging:true}}
|
||||
curSort := f.Sort.Clone()
|
||||
|
||||
// If paging with reverse cursor, change the sorting
|
||||
// direction for all columns we're sorting by
|
||||
curSort := f.Sort.Clone()
|
||||
if reversedCursor {
|
||||
curSort.Reverse()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user