/// <summary>
        /// 获取角色权限树形结构
        /// </summary>
        /// <returns></returns>
        public async Task <StatusResult <RoleTreeOutputDto> > GetRoleTreeAsync(RoleIdInputDto dto)
        {
            var result = new StatusResult <RoleTreeOutputDto>();
            //当前权限
            var rolePermission = await _rolePermissionRepository.Select.From <RoleEntity, PermissionEntity>((s, b, c) =>
                                                                                                            s.InnerJoin(a => a.RoleId == b.Id)
                                                                                                            .InnerJoin(a => a.PermissionId == c.Id)
                                                                                                            ).Where((a, b, c) => a.RoleId == dto.RoleId).ToListAsync((a, b, c) => a.PermissionId);

            var data = await _modelRepository
                       .Select
                       .ToListAsync <PermissionListOutputDto>();

            var tree = TreeHelper.GetTreeByParentId(data);

            result.Data = new RoleTreeOutputDto()
            {
                Data = tree,
                DefaultSelectedKeys = rolePermission,
                List = data
            };
            return(result);
        }
Beispiel #2
0
 /// <summary>
 /// 获取菜单树形结构
 /// </summary>
 /// <returns></returns>
 [HttpGet] public async Task <StatusResult <RoleTreeOutputDto> > GetRoleTreeAsync([FromQuery] RoleIdInputDto dto) => await _permissionContract.GetRoleTreeAsync(dto);