/// <summary>
 /// 获取数据权限条件列
 /// </summary>
 /// <param name="interfaceId">接口主键</param>
 /// <param name="objectId">对应角色或用户主键</param>
 /// <returns></returns>
 public IEnumerable <DataAuthorizeConditionEntity> GetConditionList(string interfaceId, string objectId)
 {
     try
     {
         List <DataAuthorizeRelationEntity> list           = (List <DataAuthorizeRelationEntity>)GetRelationList(interfaceId);
         DataAuthorizeRelationEntity        relationEntity = list.Find(t => t.F_ObjectId == objectId);
         if (relationEntity != null)
         {
             return(GetDataAuthorizeConditionList(relationEntity.F_Id));
         }
         else
         {
             return(new List <DataAuthorizeConditionEntity>());
         }
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
示例#2
0
 /// <summary>
 /// 保存实体数据(新增、修改)
 /// <param name="keyValue">主键</param>
 /// <summary>
 /// <returns></returns>
 public void SaveEntity(string keyValue, DataAuthorizeRelationEntity relationEntity, List <DataAuthorizeConditionEntity> conditionEntityList)
 {
     try
     {
         cache.Remove(cacheKey + relationEntity.F_InterfaceId, CacheId.dataAuthorize);
         cache.Remove(cacheKey + keyValue, CacheId.dataAuthorize);
         dataAuthorizeService.SaveEntity(keyValue, relationEntity, conditionEntityList);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
示例#3
0
        /// <summary>
        /// 保存实体数据(新增、修改)
        /// <param name="keyValue">主键</param>
        /// <summary>
        /// <returns></returns>
        public void SaveEntity(string keyValue, DataAuthorizeRelationEntity relationEntity, List <DataAuthorizeConditionEntity> conditionEntityList)
        {
            var db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    relationEntity.Modify(keyValue);
                    db.Update(relationEntity);
                    db.Delete <DataAuthorizeConditionEntity>(t => t.F_DataAuthorizeRelationId == keyValue);
                }
                else
                {
                    relationEntity.Create();
                    db.Insert(relationEntity);
                }
                int sort = 0;
                foreach (var item in conditionEntityList)
                {
                    item.Create();
                    item.F_Sort = sort;
                    item.F_DataAuthorizeRelationId = relationEntity.F_Id;
                    db.Insert(item);
                    sort++;
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }