Пример #1
0
        public async Task <ActionResult <GetResult> > List([FromQuery] SiteRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            Types.SitePermissions.SettingsCreateRule))
            {
                return(Unauthorized());
            }

            var site = await _siteRepository.GetAsync(request.SiteId);

            if (site == null)
            {
                return(this.Error("无法确定内容对应的站点"));
            }

            var channel = await _channelRepository.GetAsync(request.SiteId);

            var cascade = await _channelRepository.GetCascadeAsync(site, channel, async summary =>
            {
                var count               = await _contentRepository.GetCountAsync(site, summary);
                var entity              = await _channelRepository.GetAsync(summary.Id);
                var filePath            = await _pathManager.GetInputChannelUrlAsync(site, entity, false);
                var contentFilePathRule = string.IsNullOrEmpty(entity.ContentFilePathRule)
                    ? await _pathManager.GetContentFilePathRuleAsync(site, summary.Id)
                    : entity.ContentFilePathRule;
                return(new
                {
                    entity.IndexName,
                    Count = count,
                    FilePath = filePath,
                    ContentFilePathRule = contentFilePathRule
                });
            });

            return(new GetResult
            {
                Channel = cascade
            });
        }