示例#1
0
 /// <summary>获得权限json 
 /// </summary>
 /// <param name="rightIdList"></param>
 /// <returns></returns>
 public List<RightEntity> GetRights(List<int> rightIdList)
 {
     if (rightIdList == null || !rightIdList.Any())
         return null;
     rightIdList = rightIdList.Distinct().ToList();
     RightDal rightDal = new RightDal();
     var rightEntities = rightDal.GetRights(string.Join(",", rightIdList));
     var rootEntities = rightEntities.Where(m => m.ParentId == 0);
     return rootEntities == null ? null : rootEntities.ToList();
 }
示例#2
0
        /// <summary>添加节点 
        /// </summary>
        /// <param name="rightEntity"></param>
        /// <returns>1:成功 -1:失败 -2:已存在相同url的节点</returns>
        public int AddRight(RightEntity rightEntity)
        {
            RightDal rightDal = new RightDal();
            if (rightDal.Exist(rightEntity.Url) > 0)
            {
                return -2;
            }
            else
            {
                return rightDal.AddRight(rightEntity);

            }
        }
示例#3
0
 /// <summary>获取权限列表
 /// </summary>
 /// <returns>json字符串</returns>
 public RightEntity GetAllRights()
 {
     RightDal rightDal = new RightDal();
     var rightEntities = rightDal.GetAllRights();
     var rootEntities = rightEntities.Where(m => m.ParentId == 0);
     AppendChild(rootEntities, rightEntities);
     RightEntity rightEntity = new RightEntity();
     rightEntity.Id = 0;
     rightEntity.IsMenu = 0;
     rightEntity.Level = 0;
     rightEntity.Name = "权限管理";
     rightEntity.ParentId = 0;
     rightEntity.Url = "..";
     rightEntity.Category = -1;
     rightEntity.Deleted = 0;
     rightEntity.Describe = "..";
     rightEntity.Children = rootEntities.ToList();
     return rightEntity;
 }
示例#4
0
 public bool DeleteRight(int rightId)
 {
     RightDal rightDal = new RightDal();
     List<RightEntity> rightEntities = rightDal.GetAllRights();
     List<int> childIds = GetChildIds(rightId, rightEntities);
     childIds.Add(rightId);
     return DeleteRightRel(childIds);
     //return rightDal.DeleteRight(childIds);
 }
示例#5
0
 public bool Exist(string url)
 {
     RightDal rightDal = new RightDal();
     return rightDal.Exist(url) > 0;
 }
示例#6
0
 public List<RightEntity> GetRightEntities()
 {
     RightDal rightDal = new RightDal();
     var rightEntities = rightDal.GetAllRights();
     return rightEntities;
 }
示例#7
0
 /// <summary>获得权限列表
 /// </summary>
 /// <param name="category">插件Id</param>
 /// <returns></returns>
 public List<RightEntity> GetRights(int category)
 {
     RightDal rightDal = new RightDal();
     return rightDal.GetRights(category);
 }
示例#8
0
 /// <summary>获得所有已经启用的模块Id
 /// </summary>
 /// <returns></returns>
 public List<int> GetCategory()
 {
     RightDal rightDal = new RightDal();
     return rightDal.GetCategory();
 }
示例#9
0
        /// <summary>删除权限,真删,同时移出角色表中的权限
        /// </summary>
        /// <param name="rightId"></param>
        /// <returns></returns>
        public bool DeleteRightRel(List<int> rightIds)
        {
            foreach (var item in rightIds)
            {
                //在角色表中移出权限
                RoleDal roleDal = new RoleDal();
                roleDal.RemoveRight(item);
            }

            //删除权限
            RightDal rightDal = new RightDal();
            return rightDal.DeleteRightRel(rightIds);
        }
示例#10
0
 /// <summary>获取所有菜单
 /// </summary>
 /// <returns></returns>
 public List<RightEntity> GetAllMenu(List<string> rights, bool superAdmin)
 {
     RightDal rightDal = new RightDal();
     var rightEntities = rightDal.GetAllRights().Where(m => m.IsMenu == 1 && m.Deleted == 0);
     if (!superAdmin)
     {
         rightEntities = rightEntities.Where(m => rights.Contains(m.Id.ToString()));
     }
     var rootEntities = rightEntities.Where(m => m.ParentId == 0);
     AppendChild(rootEntities, rightEntities);
     return rootEntities.ToList();
 }
示例#11
0
 /// <summary>修改节点属性 
 /// </summary>
 /// <param name="rightEntity"></param>
 /// <returns>1:成功 -1:失败 -2:已存在相同的url</returns>
 public int UpdateRight(RightEntity rightEntity)
 {
     RightDal rightDal = new RightDal();
     int result = rightDal.Exist(rightEntity.Url);
     if (result > 0 && result != rightEntity.Id)
     {
         return -2;
     }
     return rightDal.UpdateRight(rightEntity) ? 1 : -1;
 }