3
0

Add success message to system REST endpoints (delete, suspend...)

This commit is contained in:
Denis Arh
2019-06-26 13:32:07 +02:00
parent 118d8292ba
commit 4433ef2c37
5 changed files with 19 additions and 13 deletions
+3 -1
View File
@@ -3,6 +3,8 @@ package rest
import (
"context"
"github.com/titpetric/factory/resputil"
"github.com/cortezaproject/corteza-server/system/internal/service"
"github.com/cortezaproject/corteza-server/system/rest/request"
"github.com/cortezaproject/corteza-server/system/types"
@@ -67,5 +69,5 @@ func (ctrl *Application) Read(ctx context.Context, r *request.ApplicationRead) (
}
func (ctrl *Application) Delete(ctx context.Context, r *request.ApplicationDelete) (interface{}, error) {
return nil, ctrl.svc.application.With(ctx).DeleteByID(r.ApplicationID)
return resputil.OK(), ctrl.svc.application.With(ctx).DeleteByID(r.ApplicationID)
}
+3 -2
View File
@@ -4,6 +4,7 @@ import (
"context"
"github.com/pkg/errors"
"github.com/titpetric/factory/resputil"
"github.com/cortezaproject/corteza-server/system/internal/service"
"github.com/cortezaproject/corteza-server/system/rest/request"
@@ -52,9 +53,9 @@ func (ctrl *Organisation) Update(ctx context.Context, r *request.OrganisationUpd
}
func (ctrl *Organisation) Delete(ctx context.Context, r *request.OrganisationDelete) (interface{}, error) {
return nil, ctrl.svc.org.With(ctx).Delete(r.ID)
return resputil.OK(), ctrl.svc.org.With(ctx).Delete(r.ID)
}
func (ctrl *Organisation) Archive(ctx context.Context, r *request.OrganisationArchive) (interface{}, error) {
return nil, ctrl.svc.org.With(ctx).Archive(r.ID)
return resputil.OK(), ctrl.svc.org.With(ctx).Archive(r.ID)
}
+7 -6
View File
@@ -4,6 +4,7 @@ import (
"context"
"github.com/pkg/errors"
"github.com/titpetric/factory/resputil"
"github.com/cortezaproject/corteza-server/internal/payload"
"github.com/cortezaproject/corteza-server/system/internal/service"
@@ -88,19 +89,19 @@ func (ctrl *Role) Update(ctx context.Context, r *request.RoleUpdate) (interface{
}
func (ctrl *Role) Delete(ctx context.Context, r *request.RoleDelete) (interface{}, error) {
return nil, ctrl.svc.role.With(ctx).Delete(r.RoleID)
return resputil.OK(), ctrl.svc.role.With(ctx).Delete(r.RoleID)
}
func (ctrl *Role) Archive(ctx context.Context, r *request.RoleArchive) (interface{}, error) {
return nil, ctrl.svc.role.With(ctx).Archive(r.RoleID)
return resputil.OK(), ctrl.svc.role.With(ctx).Archive(r.RoleID)
}
func (ctrl *Role) Merge(ctx context.Context, r *request.RoleMerge) (interface{}, error) {
return nil, ctrl.svc.role.With(ctx).Merge(r.RoleID, r.Destination)
return resputil.OK(), ctrl.svc.role.With(ctx).Merge(r.RoleID, r.Destination)
}
func (ctrl *Role) Move(ctx context.Context, r *request.RoleMove) (interface{}, error) {
return nil, ctrl.svc.role.With(ctx).Move(r.RoleID, r.OrganisationID)
return resputil.OK(), ctrl.svc.role.With(ctx).Move(r.RoleID, r.OrganisationID)
}
func (ctrl *Role) MemberList(ctx context.Context, r *request.RoleMemberList) (interface{}, error) {
@@ -116,9 +117,9 @@ func (ctrl *Role) MemberList(ctx context.Context, r *request.RoleMemberList) (in
}
func (ctrl *Role) MemberAdd(ctx context.Context, r *request.RoleMemberAdd) (interface{}, error) {
return nil, ctrl.svc.role.With(ctx).MemberAdd(r.RoleID, r.UserID)
return resputil.OK(), ctrl.svc.role.With(ctx).MemberAdd(r.RoleID, r.UserID)
}
func (ctrl *Role) MemberRemove(ctx context.Context, r *request.RoleMemberRemove) (interface{}, error) {
return nil, ctrl.svc.role.With(ctx).MemberRemove(r.RoleID, r.UserID)
return resputil.OK(), ctrl.svc.role.With(ctx).MemberRemove(r.RoleID, r.UserID)
}
+2 -1
View File
@@ -4,6 +4,7 @@ import (
"context"
"github.com/pkg/errors"
"github.com/titpetric/factory/resputil"
"github.com/cortezaproject/corteza-server/internal/settings"
"github.com/cortezaproject/corteza-server/system/internal/service"
@@ -56,5 +57,5 @@ func (ctrl *Settings) Get(ctx context.Context, r *request.SettingsGet) (interfac
}
func (ctrl *Settings) Set(ctx context.Context, r *request.SettingsSet) (interface{}, error) {
return nil, errors.New("Not implemented: Settings.set")
return resputil.OK(), errors.New("Not implemented: Settings.set")
}
+4 -3
View File
@@ -4,6 +4,7 @@ import (
"context"
"github.com/pkg/errors"
"github.com/titpetric/factory/resputil"
"github.com/cortezaproject/corteza-server/system/internal/service"
"github.com/cortezaproject/corteza-server/system/rest/request"
@@ -61,13 +62,13 @@ func (ctrl *User) Read(ctx context.Context, r *request.UserRead) (interface{}, e
}
func (ctrl *User) Delete(ctx context.Context, r *request.UserDelete) (interface{}, error) {
return nil, ctrl.user.With(ctx).Delete(r.UserID)
return resputil.OK(), ctrl.user.With(ctx).Delete(r.UserID)
}
func (ctrl *User) Suspend(ctx context.Context, r *request.UserSuspend) (interface{}, error) {
return nil, ctrl.user.With(ctx).Suspend(r.UserID)
return resputil.OK(), ctrl.user.With(ctx).Suspend(r.UserID)
}
func (ctrl *User) Unsuspend(ctx context.Context, r *request.UserUnsuspend) (interface{}, error) {
return nil, ctrl.user.With(ctx).Unsuspend(r.UserID)
return resputil.OK(), ctrl.user.With(ctx).Unsuspend(r.UserID)
}