/// <summary>
        /// 更新用户权限缓存
        /// </summary>
        /// <param name="userId"><用户Id/param>
        public void UpdateUserPermissionCache(string userId)
        {
            string        cacheKey    = BuildCacheKey(userId);
            List <string> permissions = new List <string>();


            var userPermissions   = _basePermissionUserRepository.Get().Where(x => x.UserId == userId).Select(x => x.PermissionValue).ToList();
            var theUser           = _baseUserRepository.Get().FirstOrDefault(x => x.UserId == userId);
            var roleIdList        = _baseUserRepository.GetUserRoleIds(userId);
            var rolePermissions   = _basePermissionRoleRepository.Get().Where(x => roleIdList.Contains(x.RoleId)).GroupBy(x => x.PermissionValue).Select(x => x.Key).ToList();
            var existsPermissions = userPermissions.Concat(rolePermissions).Distinct();

            permissions = existsPermissions.ToList();
            CacheHelper.Cache.SetCache(cacheKey, permissions);
        }
Beispiel #2
0
 public static List <string> GetUserRoleIds(string userId)
 {
     return(_baseUserRepository.GetUserRoleIds(userId));
 }