/// <summary> /// 删除实体角色信息信息 /// </summary> /// <param name="ids">要删除的实体角色信息编号</param> /// <returns>业务操作结果</returns> public virtual async Task <OperationResult> DeleteEntityRoles(params Guid[] ids) { List <(string, string)> list = new List <(string, string)>(); OperationResult result = await _entityRoleRepository.DeleteAsync(ids, async entity => { TRole role = await _roleRepository.GetAsync(entity.RoleId); TEntityInfo entityInfo = await _entityInfoRepository.GetAsync(entity.EntityId); if (role != null && entityInfo != null) { list.Add((role.Name, entityInfo.TypeName)); } }); if (result.Successed && list.Count > 0) { //移除数据权限缓存 IDataAuthCache cache = ServiceLocator.Instance.GetService <IDataAuthCache>(); foreach ((string roleName, string typeName) in list) { cache.RemoveCache(roleName, typeName, DataAuthOperation.Delete); } } return(result); }
/// <summary> /// 事件处理 /// </summary> /// <param name="eventData">事件源数据</param> public override void Handle(DataAuthCacheRefreshEventData eventData) { //更新缓存项 foreach (DataAuthCacheItem cacheItem in eventData.SetItems) { _authCache.SetCache(cacheItem); } //移除缓存项 foreach (DataAuthCacheItem cacheItem in eventData.RemoveItems) { _authCache.RemoveCache(cacheItem); } }
/// <summary> /// 事件处理 /// </summary> /// <param name="eventData">事件源数据</param> public override void Handle(DataAuthCacheRefreshEventData eventData) { IDataAuthCache cache = ServiceLocator.Instance.GetService <IDataAuthCache>(); //更新缓存项 foreach (DataAuthCacheItem cacheItem in eventData.SetItems) { cache.SetCache(cacheItem); } //移除缓存项 foreach (DataAuthCacheItem cacheItem in eventData.RemoveItems) { cache.RemoveCache(cacheItem); } }