Пример #1
0
        /// <summary>
        /// 根据角色id获取角色下的权限
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public List <ServPurviewInfoCustom> GetPurviewInfoByRoleId(int roleId)
        {
            try
            {
                List <ServPurviewInfoCustom> purviewList = new List <ServPurviewInfoCustom>();
                //根据角色id获取角色所包含的园区权限
                List <ServRolePurviewModel> rolePurList = servPurviewInfoDAL.GetRoleRegionIdByRoleId(roleId);
                for (int i = 0; i < rolePurList.Count; i++)
                {
                    ServRolePurviewQuery query = new ServRolePurviewQuery();
                    query.role_id   = roleId;
                    query.region_id = rolePurList[i].region_id;
                    List <ServPurviewInfoModel> purviewList1 = servPurviewInfoDAL.GetPurviewInfoByRoleId(query);
                    for (int j = 0; j < purviewList1.Count; j++)
                    {
                        ServPurviewInfoCustom purCus = new ServPurviewInfoCustom();
                        purCus.id           = purviewList1[j].id;
                        purCus.purview_code = purviewList1[j].purview_code;
                        purCus.purview_name = purviewList1[j].purview_name;
                        purCus.sid          = Convert.ToInt32(purviewList1[j].purview_code + "" + rolePurList[i].region_id);
                        if (purviewList1[j].pid == -1)
                        {
                            purCus.pid = rolePurList[i].region_id;
                        }
                        else
                        {
                            purCus.pid = Convert.ToInt32(purviewList1[j].pid + "" + rolePurList[i].region_id);
                        }
                        purCus.region_id = rolePurList[i].region_id;
                        purviewList.Add(purCus);
                    }
                    //根据园区id获取园区信息
                    BaseRegionConfigModel regionModel = baseRegionConfigDAL.GetEntity(rolePurList[i].region_id);
                    ServPurviewInfoCustom purCus1     = new ServPurviewInfoCustom();
                    if (regionModel != null)
                    {
                        purCus1.id           = regionModel.id;
                        purCus1.purview_name = regionModel.region_name;
                        purCus1.purview_code = regionModel.id;
                        purCus1.pid          = -1;
                        purCus1.sid          = regionModel.id;
                    }
                    else
                    {
                        purCus1.purview_name = "超级管理员";
                    }
                    purCus1.region_id = rolePurList[i].region_id;
                    purviewList.Add(purCus1);
                }

                return(purviewList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
 /// <summary>
 /// 根据角色id和园区id获取角色下的权限
 /// </summary>
 /// <param name="roleId"></param>
 /// <returns></returns>
 public List <ServPurviewInfoModel> GetPurviewInfoByRoleId(ServRolePurviewQuery query)
 {
     try
     {
         return(mapContext.QueryForList <ServPurviewInfoModel>("GetPurviewInfoByRoleId", query).ToList());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #3
0
 /// <summary>
 /// 根据角色id和园区id获取权限
 /// </summary>
 /// <param name="roleId"></param>
 /// <param name="regionId"></param>
 /// <returns></returns>
 public List <ServPurviewInfoModel> GetPurviewInfoByRoleIdAndRegionId(int roleId, int regionId)
 {
     try
     {
         ServRolePurviewQuery query = new ServRolePurviewQuery();
         query.role_id   = roleId;
         query.region_id = regionId;
         List <ServPurviewInfoModel> purviewList = servPurviewInfoDAL.GetPurviewInfoByRoleId(query);
         return(purviewList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #4
0
        //public bool RolePurviewBindByCheckEX(int roleId, int regionId, string purviewCode)
        //{
        //    try
        //    {
        //        bool result = false;
        //        string[] codeArray = purviewCode.Split(',');
        //        //根据角色id和园区id删除
        //        for (int i = 0; i < codeArray.Length; i++)
        //        {

        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}
        #endregion

        #region
        /// <summary>
        /// 根据角色判断是否拥有园区以及地图页面的权限
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="regionId"></param>
        /// <returns></returns>
        public bool GetPersonMapAndRegionPurviewByRole(int roleId, int regionId)
        {
            try
            {
                bool res = false;
                ServRolePurviewQuery query = new ServRolePurviewQuery();
                query.region_id = regionId;
                query.role_id   = roleId;
                List <ServRolePurviewModel> list = servRolePurviewDAL.GetRolePurviewByRoleIdAndRegionId(query);
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].purview_id == (int)EnumClass.PurviewEnum.地图模块)
                    {
                        res = true;
                        return(res);
                    }
                }
                return(res);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }