|
|
@ -26,7 +26,6 @@ using Squidex.Pipeline; |
|
|
|
|
|
|
|
|
namespace Squidex.Controllers.ContentApi |
|
|
namespace Squidex.Controllers.ContentApi |
|
|
{ |
|
|
{ |
|
|
[MustBeAppEditor] |
|
|
|
|
|
[ApiExceptionFilter] |
|
|
[ApiExceptionFilter] |
|
|
[AppApi] |
|
|
[AppApi] |
|
|
[SwaggerIgnore] |
|
|
[SwaggerIgnore] |
|
|
@ -48,6 +47,7 @@ namespace Squidex.Controllers.ContentApi |
|
|
this.contentRepository = contentRepository; |
|
|
this.contentRepository = contentRepository; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MustBeAppReader] |
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("content/{app}/graphql")] |
|
|
[Route("content/{app}/graphql")] |
|
|
[ApiCosts(2)] |
|
|
[ApiCosts(2)] |
|
|
@ -58,6 +58,7 @@ namespace Squidex.Controllers.ContentApi |
|
|
return Ok(result); |
|
|
return Ok(result); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MustBeAppReader] |
|
|
[HttpPost] |
|
|
[HttpPost] |
|
|
[Route("content/{app}/graphql")] |
|
|
[Route("content/{app}/graphql")] |
|
|
[ApiCosts(2)] |
|
|
[ApiCosts(2)] |
|
|
@ -68,10 +69,11 @@ namespace Squidex.Controllers.ContentApi |
|
|
return Ok(result); |
|
|
return Ok(result); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MustBeAppReader] |
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("content/{app}/{name}")] |
|
|
[Route("content/{app}/{name}")] |
|
|
[ApiCosts(2)] |
|
|
[ApiCosts(2)] |
|
|
public async Task<IActionResult> GetContents(string name, [FromQuery] bool nonPublished = false, [FromQuery] bool hidden = false, [FromQuery] string ids = null) |
|
|
public async Task<IActionResult> GetContents(string name, [FromQuery] string ids = null) |
|
|
{ |
|
|
{ |
|
|
var schemaEntity = await FindSchemaAsync(name); |
|
|
var schemaEntity = await FindSchemaAsync(name); |
|
|
|
|
|
|
|
|
@ -88,10 +90,12 @@ namespace Squidex.Controllers.ContentApi |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var isFrontendClient = User.IsFrontendClient(); |
|
|
|
|
|
|
|
|
var query = Request.QueryString.ToString(); |
|
|
var query = Request.QueryString.ToString(); |
|
|
|
|
|
|
|
|
var taskForItems = contentRepository.QueryAsync(App, schemaEntity.Id, nonPublished, idsList, query); |
|
|
var taskForItems = contentRepository.QueryAsync(App, schemaEntity.Id, isFrontendClient, idsList, query); |
|
|
var taskForCount = contentRepository.CountAsync(App, schemaEntity.Id, nonPublished, idsList, query); |
|
|
var taskForCount = contentRepository.CountAsync(App, schemaEntity.Id, isFrontendClient, idsList, query); |
|
|
|
|
|
|
|
|
await Task.WhenAll(taskForItems, taskForCount); |
|
|
await Task.WhenAll(taskForItems, taskForCount); |
|
|
|
|
|
|
|
|
@ -104,7 +108,7 @@ namespace Squidex.Controllers.ContentApi |
|
|
|
|
|
|
|
|
if (x.Data != null) |
|
|
if (x.Data != null) |
|
|
{ |
|
|
{ |
|
|
itemModel.Data = x.Data.ToApiModel(schemaEntity.Schema, App.LanguagesConfig); |
|
|
itemModel.Data = x.Data.ToApiModel(schemaEntity.Schema, App.LanguagesConfig, null, !isFrontendClient); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return itemModel; |
|
|
return itemModel; |
|
|
@ -114,10 +118,11 @@ namespace Squidex.Controllers.ContentApi |
|
|
return Ok(response); |
|
|
return Ok(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MustBeAppReader] |
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
[Route("content/{app}/{name}/{id}")] |
|
|
[Route("content/{app}/{name}/{id}")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
public async Task<IActionResult> GetContent(string name, Guid id, bool hidden = false) |
|
|
public async Task<IActionResult> GetContent(string name, Guid id) |
|
|
{ |
|
|
{ |
|
|
var schemaEntity = await FindSchemaAsync(name); |
|
|
var schemaEntity = await FindSchemaAsync(name); |
|
|
|
|
|
|
|
|
@ -137,7 +142,9 @@ namespace Squidex.Controllers.ContentApi |
|
|
|
|
|
|
|
|
if (entity.Data != null) |
|
|
if (entity.Data != null) |
|
|
{ |
|
|
{ |
|
|
response.Data = entity.Data.ToApiModel(schemaEntity.Schema, App.LanguagesConfig, null, hidden); |
|
|
var isFrontendClient = User.IsFrontendClient(); |
|
|
|
|
|
|
|
|
|
|
|
response.Data = entity.Data.ToApiModel(schemaEntity.Schema, App.LanguagesConfig, null, !isFrontendClient); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Response.Headers["ETag"] = new StringValues(entity.Version.ToString()); |
|
|
Response.Headers["ETag"] = new StringValues(entity.Version.ToString()); |
|
|
@ -145,6 +152,7 @@ namespace Squidex.Controllers.ContentApi |
|
|
return Ok(response); |
|
|
return Ok(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MustBeAppEditor] |
|
|
[HttpPost] |
|
|
[HttpPost] |
|
|
[Route("content/{app}/{name}/")] |
|
|
[Route("content/{app}/{name}/")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
@ -160,6 +168,7 @@ namespace Squidex.Controllers.ContentApi |
|
|
return CreatedAtAction(nameof(GetContent), new { id = response.Id }, response); |
|
|
return CreatedAtAction(nameof(GetContent), new { id = response.Id }, response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MustBeAppEditor] |
|
|
[HttpPut] |
|
|
[HttpPut] |
|
|
[Route("content/{app}/{name}/{id}")] |
|
|
[Route("content/{app}/{name}/{id}")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
@ -172,6 +181,7 @@ namespace Squidex.Controllers.ContentApi |
|
|
return NoContent(); |
|
|
return NoContent(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MustBeAppEditor] |
|
|
[HttpPatch] |
|
|
[HttpPatch] |
|
|
[Route("content/{app}/{name}/{id}")] |
|
|
[Route("content/{app}/{name}/{id}")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
@ -184,6 +194,7 @@ namespace Squidex.Controllers.ContentApi |
|
|
return NoContent(); |
|
|
return NoContent(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MustBeAppEditor] |
|
|
[HttpPut] |
|
|
[HttpPut] |
|
|
[Route("content/{app}/{name}/{id}/publish")] |
|
|
[Route("content/{app}/{name}/{id}/publish")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
@ -196,6 +207,7 @@ namespace Squidex.Controllers.ContentApi |
|
|
return NoContent(); |
|
|
return NoContent(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MustBeAppEditor] |
|
|
[HttpPut] |
|
|
[HttpPut] |
|
|
[Route("content/{app}/{name}/{id}/unpublish")] |
|
|
[Route("content/{app}/{name}/{id}/unpublish")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
@ -208,6 +220,7 @@ namespace Squidex.Controllers.ContentApi |
|
|
return NoContent(); |
|
|
return NoContent(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MustBeAppEditor] |
|
|
[HttpDelete] |
|
|
[HttpDelete] |
|
|
[Route("content/{app}/{name}/{id}")] |
|
|
[Route("content/{app}/{name}/{id}")] |
|
|
[ApiCosts(1)] |
|
|
[ApiCosts(1)] |
|
|
|