From eff23539546e2b2f44dc82f53af6b8fa2a2ba47c Mon Sep 17 00:00:00 2001 From: chenos Date: Mon, 18 Jan 2021 19:21:58 +0800 Subject: [PATCH] fix: update collections.roles actions --- .../src/actions/collections.roles.ts | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/plugin-permissions/src/actions/collections.roles.ts b/packages/plugin-permissions/src/actions/collections.roles.ts index 2b73276e76..eab23ed542 100644 --- a/packages/plugin-permissions/src/actions/collections.roles.ts +++ b/packages/plugin-permissions/src/actions/collections.roles.ts @@ -1,7 +1,38 @@ -import { actions } from '@nocobase/actions'; +import { actions, middlewares } from '@nocobase/actions'; +import * as rolesCollectionsActions from './roles.collections'; export async function list(ctx: actions.Context, next: actions.Next) { // TODO: 暂时 action 中间件就这么写了 - ctx.action.mergeParams({associated: null}); + ctx.action.mergeParams({ + associated: null, + }); return actions.common.list(ctx, next); } + +export async function get(ctx: actions.Context, next: actions.Next) { + const { resourceName, resourceKey, associatedName, associatedKey } = ctx.action.params; + ctx.action.mergeParams({ + associated: null, + resourceName: associatedName, + resourceKey: associatedKey, + associatedName: resourceName, + associatedKey: resourceKey, + }); + await middlewares.associated(ctx, async () => { + }); + return rolesCollectionsActions.get(ctx, next); +} + +export async function update(ctx: actions.Context, next: actions.Next) { + const { resourceName, resourceKey, associatedName, associatedKey } = ctx.action.params; + ctx.action.mergeParams({ + associated: null, + resourceName: associatedName, + resourceKey: associatedKey, + associatedName: resourceName, + associatedKey: resourceKey, + }); + await middlewares.associated(ctx, async () => { + }); + return rolesCollectionsActions.update(ctx, next); +}