Exemplo n.º 1
0
        /// <summary>
        ///     根据菜单Id获取数据权限规则
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <IEnumerable <SystemDataOutput> > GetDataByMenuId(SystemDataGetDataByMenuIdInput input)
        {
            var datas = (await _dataRepository.GetDataByMenuId(input)).ToList();
            var menus = (await _menuRepository.FindAllAsync()).ToList();

            foreach (var item in datas)
            {
                var menu = menus.FirstOrDefault(w => w.MenuId == item.MenuId);
                if (menu != null && !menu.ParentIds.IsNullOrEmpty())
                {
                    foreach (var parent in menu.ParentIds.Split(','))
                    {
                        //查找上级
                        var dicinfo = menus.FirstOrDefault(w => w.MenuId.ToString() == parent);
                        if (dicinfo != null)
                        {
                            item.MenuNames += dicinfo.Name + ">";
                        }
                    }
                    if (!item.MenuNames.IsNullOrEmpty())
                    {
                        item.MenuNames = item.MenuNames.TrimEnd('>');
                    }
                }
            }
            return(datas);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     查询对应拥有的功能项菜单信息
        /// </summary>
        /// <param name="privilegeMasterValue">信息</param>
        /// <param name="privilegeMaster"></param>
        /// <returns></returns>
        public async Task <IEnumerable <SystemData> > GetDataByPrivilegeMaster(Guid privilegeMasterValue,
                                                                               EnumPrivilegeMaster privilegeMaster)
        {
            IList <SystemData> datas = new List <SystemData>();
            //获取拥有的菜单信息
            var menus = await GetMenuHavePermissionByPrivilegeMasterValue(new GetMenuHavePermissionByPrivilegeMasterValueInput
            {
                PrivilegeMasterValue = privilegeMasterValue,
                PrivilegeMaster      = privilegeMaster,
                PrivilegeAccess      = EnumPrivilegeAccess.数据权限
            });

            //获取拥有的功能项信息
            IList <SystemPermission> haveDatas = (await
                                                  GetPermissionByPrivilegeMasterValue(
                                                      new GetPermissionByPrivilegeMasterValueInput()
            {
                PrivilegeAccess = EnumPrivilegeAccess.数据权限,
                PrivilegeMasterValue = privilegeMasterValue,
                PrivilegeMaster = privilegeMaster
            })).ToList();

            //获取所有功能项
            IList <SystemDataDoubleWayDto> functionDtos = (await _dataRepository.GetDataByMenuId()).ToList();

            foreach (var menu in menus)
            {
                var function = functionDtos.Where(w => w.MenuId == (Guid)menu.id).OrderBy(o => o.OrderNo);
                foreach (var f in function)
                {
                    var selectFunction = haveDatas.Where(w => w.PrivilegeAccessValue == f.DataId);
                    f.Remark = selectFunction.Any() ? "selected" : "";
                    datas.Add(f);
                }
            }
            return(datas);
        }
Exemplo n.º 3
0
 /// <summary>
 ///     根据菜单Id获取数据权限规则
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public async Task <IEnumerable <SystemDataDoubleWayDto> > GetDataByMenuId(NullableIdInput <Guid> input)
 {
     return(await _dataRepository.GetDataByMenuId(input));
 }