Added update to shared module service
This commit is contained in:
@@ -26,15 +26,6 @@ func (ctrl ManageStructure) CreateExposed(ctx context.Context, r *request.Manage
|
||||
Fields: r.Fields,
|
||||
}
|
||||
)
|
||||
|
||||
if r.ComposeModuleID == 0 {
|
||||
return nil, errors.New("TODO - http 400 bad request - use compose module id in request")
|
||||
}
|
||||
|
||||
if r.ComposeNamespaceID == 0 {
|
||||
return nil, errors.New("TODO - http 400 bad request - use compose namespace id in request")
|
||||
}
|
||||
|
||||
return (service.DefaultExposedModule).Create(ctx, mod)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ type (
|
||||
FindByID(ctx context.Context, nodeID uint64, moduleID uint64) (*types.SharedModule, error)
|
||||
FindByAny(ctx context.Context, nodeID uint64, identifier interface{}) (*types.SharedModule, error)
|
||||
Create(ctx context.Context, new *types.SharedModule) (*types.SharedModule, error)
|
||||
Update(ctx context.Context, updated *types.SharedModule) (*types.SharedModule, error)
|
||||
// DeleteByID(ctx context.Context, nodeID, moduleID uint64) error
|
||||
}
|
||||
|
||||
@@ -109,6 +110,26 @@ func (svc sharedModule) Create(ctx context.Context, new *types.SharedModule) (*t
|
||||
return new, svc.recordAction(ctx, aProps, SharedModuleActionCreate, err)
|
||||
}
|
||||
|
||||
func (svc sharedModule) Update(ctx context.Context, updated *types.SharedModule) (*types.SharedModule, error) {
|
||||
var (
|
||||
aProps = &sharedModuleActionProps{module: updated}
|
||||
)
|
||||
|
||||
err := store.Tx(ctx, svc.store, func(ctx context.Context, s store.Storer) (err error) {
|
||||
updated.UpdatedAt = now()
|
||||
|
||||
aProps.setModule(updated)
|
||||
|
||||
if err = store.UpdateFederationSharedModule(ctx, s, updated); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return updated, svc.recordAction(ctx, aProps, SharedModuleActionUpdate, err)
|
||||
}
|
||||
|
||||
func (svc sharedModule) uniqueCheck(ctx context.Context, m *types.SharedModule) (err error) {
|
||||
f := types.SharedModuleFilter{
|
||||
NodeID: m.NodeID,
|
||||
|
||||
@@ -21,8 +21,9 @@ type (
|
||||
}
|
||||
|
||||
SharedModuleFilter struct {
|
||||
NodeID uint64 `json:"nodeID,string"`
|
||||
Query string `json:"query"`
|
||||
NodeID uint64 `json:"nodeID,string"`
|
||||
ExternalFederationModuleID uint64 `json:"externalFederationModuleID,string"`
|
||||
Query string `json:"query"`
|
||||
|
||||
Handle string `json:"handle"`
|
||||
Name string `json:"name"`
|
||||
|
||||
Reference in New Issue
Block a user