/// <summary>
        /// 获取某角色菜单权限
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <IList <PowerSelectViewResponse> > GetRoleMenu(RoleMenuRequestDto input)
        {
            var roleMenuDtos = await _roleMenuAppService.GetMenuByRoleIdsAsync(new List <string> {
                input.RoleId
            });

            return(roleMenuDtos.Select(o => new PowerSelectViewResponse {
                Id = o.MenuId
            }).ToList());
        }
Exemple #2
0
        private async Task <IList <PowerSelectViewResponse> > GetEmployeeMenuAsync(string employeeId)
        {
            var employeeMenuDtos = await _employeeMenuAppService.GetMenuByEmployeeIdAsync(employeeId);

            // return employeeMenuDtos.Select(o => new PowerSelectViewResponse { Id = o.MenuId }).ToList();
            var empMenuIds = employeeMenuDtos.Select(e => e.MenuId).ToList();
            //1.查询该人员所在机构下所拥有的菜单权限
            var relationOrgEmpViews = await _relationOrganizationEmployeeAppService.GetOrgIdsByEmployeeIds(new List <string> {
                employeeId
            });

            var orgIds       = relationOrgEmpViews.Select(r => r.OrganizationId).ToList();
            var orgMenuViews = await _organizationMenuAppService.GetMenuByOrgIdsAsync(orgIds);

            var orgMenuIds = orgMenuViews.Select(o => o.MenuId).ToList();

            //2.查询该人员所在角色下所拥有的的菜单权限
            var relationRoleEmpViews = await _relationEmployeeRoleAppService.GetRoleIdsByEmployeeIds(new List <string> {
                employeeId
            });

            var roleIds       = relationRoleEmpViews.Select(r => r.RoleId).ToList();
            var roleMenuViews = await _roleMenuAppService.GetMenuByRoleIdsAsync(roleIds);

            var roleMenuIds = roleMenuViews.Select(r => r.MenuId).ToList();


            //3.移除个人菜单中与机构、角色重复的
            empMenuIds.RemoveAll(e => orgMenuIds.Contains(e));
            empMenuIds.RemoveAll(e => roleMenuIds.Contains(e));

            //4.继承自机构的菜单权限,标记为禁止取消
            var powerSelectOrg = orgMenuIds.Select(o => new PowerSelectViewResponse {
                Id = o, Disabled = true
            });
            //5.继承自角色的菜单权限,标记为禁止取消
            var powerSelectRole = roleMenuIds.Select(r => new PowerSelectViewResponse {
                Id = r, Disabled = true
            });

            var powerSelectEmp = empMenuIds.Select(e => new PowerSelectViewResponse {
                Id = e
            });

            return(powerSelectOrg.Concat(powerSelectRole).Concat(powerSelectEmp).ToList());
        }