コード例 #1
0
        public async Task <ActionResult <DeleteResult> > Delete([FromBody] SpecialIdRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            MenuUtils.SitePermissions.Specials))
            {
                return(Unauthorized());
            }

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

            var specialInfo = await _pathManager.DeleteSpecialAsync(site, request.SpecialId);

            await _authManager.AddSiteLogAsync(request.SiteId,
                                               "删除专题",
                                               $"专题名称:{specialInfo.Title}");

            var specials = await _specialRepository.GetSpecialsAsync(request.SiteId);

            foreach (var special in specials)
            {
                var filePath = PathUtils.Combine(await _pathManager.GetSpecialDirectoryPathAsync(site, special.Url), "index.html");
                special.Set("editable", FileUtils.IsFileExists(filePath));
            }

            return(new DeleteResult
            {
                Specials = specials
            });
        }
コード例 #2
0
        public async Task <ActionResult <StringResult> > Download([FromBody] SpecialIdRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            MenuUtils.SitePermissions.Specials))
            {
                return(Unauthorized());
            }

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

            var specialInfo = await _specialRepository.GetSpecialAsync(request.SiteId, request.SpecialId);

            var directoryPath = await _pathManager.GetSpecialDirectoryPathAsync(site, specialInfo.Url);

            var srcDirectoryPath = _pathManager.GetSpecialSrcDirectoryPath(directoryPath);
            var zipFilePath      = _pathManager.GetSpecialZipFilePath(specialInfo.Title, directoryPath);

            FileUtils.DeleteFileIfExists(zipFilePath);
            _pathManager.CreateZip(zipFilePath, srcDirectoryPath);
            var url = await _pathManager.GetSpecialZipFileUrlAsync(site, specialInfo);

            return(new StringResult
            {
                Value = url
            });
        }
コード例 #3
0
        public async Task <ActionResult <DeleteResult> > Delete([FromBody] SpecialIdRequest request)
        {
            if (!await _authManager.HasSitePermissionsAsync(request.SiteId,
                                                            Types.SitePermissions.Specials))
            {
                return(Unauthorized());
            }

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

            var specialInfo = await _pathManager.DeleteSpecialAsync(site, request.SpecialId);

            await _authManager.AddSiteLogAsync(request.SiteId,
                                               "删除专题",
                                               $"专题名称:{specialInfo.Title}");

            var specialInfoList = await _specialRepository.GetSpecialsAsync(request.SiteId);

            return(new DeleteResult
            {
                Specials = specialInfoList
            });
        }