Update context.go

新增多角色
This commit is contained in:
HHC26 2024-07-11 11:53:18 +08:00 committed by GitHub
parent f78f44e00f
commit 4594cc3b7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -78,22 +78,22 @@ func GetUserId(ctx context.Context) int64 {
return user.Id return user.Id
} }
// GetRoleId 获取用户角色ID // GetRoleIds 获取用户所有角色ID
func GetRoleId(ctx context.Context) int64 { func GetRoleIds(ctx context.Context) []int64 {
user := GetUser(ctx) user := GetUser(ctx)
if user == nil { if user == nil {
return 0 return nil
} }
return user.RoleId return user.RoleIds
} }
// GetRoleKey 获取用户角色唯一编码 // GetRoleKey 获取用户所有角色编码
func GetRoleKey(ctx context.Context) string { func GetRoleKey(ctx context.Context) []string {
user := GetUser(ctx) user := GetUser(ctx)
if user == nil { if user == nil {
return "" return nil
} }
return user.RoleKey return user.RoleKeys
} }
// GetDeptType 获取用户部门类型 // GetDeptType 获取用户部门类型