From 4594cc3b7e826b4099732556f4ecdff066df7438 Mon Sep 17 00:00:00 2001 From: HHC26 <44391821+HHC26@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:53:18 +0800 Subject: [PATCH] Update context.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增多角色 --- server/internal/library/contexts/context.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/internal/library/contexts/context.go b/server/internal/library/contexts/context.go index b9cd6bd..0f57ed8 100644 --- a/server/internal/library/contexts/context.go +++ b/server/internal/library/contexts/context.go @@ -78,22 +78,22 @@ func GetUserId(ctx context.Context) int64 { return user.Id } -// GetRoleId 获取用户角色ID -func GetRoleId(ctx context.Context) int64 { +// GetRoleIds 获取用户所有角色ID +func GetRoleIds(ctx context.Context) []int64 { user := GetUser(ctx) if user == nil { - return 0 + return nil } - return user.RoleId + return user.RoleIds } -// GetRoleKey 获取用户角色唯一编码 -func GetRoleKey(ctx context.Context) string { +// GetRoleKey 获取用户所有角色编码 +func GetRoleKey(ctx context.Context) []string { user := GetUser(ctx) if user == nil { - return "" + return nil } - return user.RoleKey + return user.RoleKeys } // GetDeptType 获取用户部门类型