Ejemplo n.º 1
0
        /// <summary>
        /// 设置AppId权限
        /// </summary>
        /// <param name="appId">AppId</param>
        /// <param name="permissions">权限值列表</param>
        public void SetAppIdPermission(string appId, List <string> permissions)
        {
            //更新缓存
            string cacheKey = BuildCacheKey(appId);

            CacheHelper.Cache.SetCache(cacheKey, permissions);

            //更新数据库
            _appIdRepository.Delete(appId);


            List <Base_PermissionAppId> insertList = new List <Base_PermissionAppId>();

            permissions.ForEach(newPermission =>
            {
                insertList.Add(new Base_PermissionAppId
                {
                    //Id = Guid.NewGuid().ToSequentialGuid(),
                    AppId           = appId,
                    PermissionValue = newPermission
                });
            });

            _appIdRepository.AddRange(insertList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存权限
        /// </summary>
        /// <param name="appId">应用Id</param>
        /// <param name="permissions">权限值</param>
        public void SavePermission(string appId, List <string> permissions)
        {
            _appIdRepository.Delete(x => x.AppId == appId);

            List <Base_PermissionAppId> insertList = new List <Base_PermissionAppId>();

            permissions.ForEach(newPermission =>
            {
                insertList.Add(new Base_PermissionAppId
                {
                    AppId           = appId,
                    PermissionValue = newPermission
                });
            });

            _appIdRepository.AddRange(insertList);
        }