#400 pdf get all anonymous api
This commit is contained in:
parent
e2b1a15fad
commit
053e058ea1
@ -14,6 +14,8 @@ using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using RSecurityBackend.Services;
|
||||
using RMuseum.Services.Implementation;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace RMuseum.Controllers
|
||||
{
|
||||
@ -21,6 +23,44 @@ namespace RMuseum.Controllers
|
||||
[Route("api/pdf")]
|
||||
public class PDFLibraryController : Controller
|
||||
{
|
||||
/// <summary>
|
||||
///get all published pdfbooks (including CoverImage info but not pages or tagibutes info) - check paging-headers for paging info
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<PDFBook>))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
|
||||
public async Task<IActionResult> GetAllPDFBooks([FromQuery] PagingParameterModel paging)
|
||||
{
|
||||
var pdfBooksInfo = await _pdfService.GetAllPDFBooks(paging, new PublishStatus[] { PublishStatus.Published });
|
||||
if (!string.IsNullOrEmpty(pdfBooksInfo.ExceptionString))
|
||||
{
|
||||
return BadRequest(pdfBooksInfo.ExceptionString);
|
||||
}
|
||||
|
||||
if (pdfBooksInfo.Result.Books.Count() > 0)
|
||||
{
|
||||
DateTime lastModification = pdfBooksInfo.Result.Books.Max(i => i.LastModified);
|
||||
Response.GetTypedHeaders().LastModified = lastModification;
|
||||
|
||||
var requestHeaders = Request.GetTypedHeaders();
|
||||
if (requestHeaders.IfModifiedSince.HasValue &&
|
||||
requestHeaders.IfModifiedSince.Value >= lastModification)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status304NotModified);
|
||||
}
|
||||
}
|
||||
|
||||
// Paging Header
|
||||
HttpContext.Response.Headers.Add("paging-headers", JsonConvert.SerializeObject(pdfBooksInfo.Result.PagingMeta));
|
||||
|
||||
return Ok(pdfBooksInfo.Result.Books);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// start importing a local pdf file
|
||||
/// </summary>
|
||||
|
||||
@ -2343,6 +2343,13 @@
|
||||
<param name="numberingService"></param>
|
||||
<param name="configuration"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.PDFLibraryController.GetAllPDFBooks(RSecurityBackend.Models.Generic.PagingParameterModel)">
|
||||
<summary>
|
||||
get all published pdfbooks (including CoverImage info but not pages or tagibutes info) - check paging-headers for paging info
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.PDFLibraryController.StartImportingLocalPDFAsync(RMuseum.Models.PDFLibrary.ViewModels.NewPDFBookViewModel)">
|
||||
<summary>
|
||||
start importing a local pdf file
|
||||
@ -17514,6 +17521,14 @@
|
||||
<param name="statusArray"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.GetAllPDFBooks(RSecurityBackend.Models.Generic.PagingParameterModel,RMuseum.Models.Artifact.PublishStatus[])">
|
||||
<summary>
|
||||
get all pdfbooks (including CoverImage info but not pages or tagibutes info)
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<param name="statusArray"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.StartImportingLocalPDFAsync(RMuseum.Models.PDFLibrary.ViewModels.NewPDFBookViewModel)">
|
||||
<summary>
|
||||
start importing local pdf file
|
||||
@ -18385,6 +18400,14 @@
|
||||
<param name="statusArray"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IPDFLibraryService.GetAllPDFBooks(RSecurityBackend.Models.Generic.PagingParameterModel,RMuseum.Models.Artifact.PublishStatus[])">
|
||||
<summary>
|
||||
get all pdfbooks (including CoverImage info but not pages or tagibutes info)
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<param name="statusArray"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IPDFLibraryService.AddAuthorAsync(RMuseum.Models.PDFLibrary.Author)">
|
||||
<summary>
|
||||
add author
|
||||
|
||||
@ -19,6 +19,14 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<PDFBook>> GetPDFBookByIdAsync(int id, PublishStatus[] statusArray);
|
||||
|
||||
/// <summary>
|
||||
/// get all pdfbooks (including CoverImage info but not pages or tagibutes info)
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <param name="statusArray"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<(PaginationMetadata PagingMeta, PDFBook[] Books)>> GetAllPDFBooks(PagingParameterModel paging, PublishStatus[] statusArray);
|
||||
|
||||
/// <summary>
|
||||
/// add author
|
||||
/// </summary>
|
||||
|
||||
@ -51,6 +51,25 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get all pdfbooks (including CoverImage info but not pages or tagibutes info)
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <param name="statusArray"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<(PaginationMetadata PagingMeta, PDFBook[] Books)>> GetAllPDFBooks(PagingParameterModel paging, PublishStatus[] statusArray)
|
||||
{
|
||||
var source =
|
||||
_context.PDFBooks.AsNoTracking()
|
||||
.Include(a => a.CoverImage)
|
||||
.Where(a => statusArray.Contains(a.Status))
|
||||
.OrderByDescending(t => t.DateTime)
|
||||
.AsQueryable();
|
||||
(PaginationMetadata PagingMeta, PDFBook[] Books) paginatedResult =
|
||||
await QueryablePaginator<PDFBook>.Paginate(source, paging);
|
||||
return new RServiceResult<(PaginationMetadata PagingMeta, PDFBook[] Books)>(paginatedResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// start importing local pdf file
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user