This commit is contained in:
2020-08-26 23:49:10 +00:00
parent 76e9b232c6
commit 0011161a39
3 changed files with 58 additions and 5 deletions

View File

@@ -162,6 +162,36 @@ namespace AyaNova.Api.Controllers
//======================================================================================================
public class ObjectReportDataParameter
{
public AyaType ObjectType { get; set; }
public long[] ObjectIdArray { get; set; }
}
/// <summary>
/// Get data from id list in format used by report designer
/// </summary>
/// <param name="reportDataParam">report id and object id values for object type specified in report template</param>
/// <param name="apiVersion">From route path</param>
/// <returns></returns>
[HttpPost("object-report-data")]
public async Task<IActionResult> GetReportData([FromBody] ObjectReportDataParameter reportDataParam, ApiVersion apiVersion)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
ReportBiz biz = ReportBiz.GetBiz(ct, HttpContext);
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
var reportData = await biz.GetReportData(reportDataParam.ObjectType, reportDataParam.ObjectIdArray);
if (reportData == null)
return BadRequest(new ApiErrorResponse(biz.Errors));
else
return Ok(ApiOkResponse.Response(reportData));
}
/// <summary>
/// Render Report
/// </summary>
@@ -174,7 +204,7 @@ namespace AyaNova.Api.Controllers
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
ReportBiz biz = ReportBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
@@ -182,7 +212,7 @@ namespace AyaNova.Api.Controllers
var httpConnectionFeature = HttpContext.Features.Get<IHttpConnectionFeature>();
var API_URL = $"http://127.0.0.1:{httpConnectionFeature.LocalPort}/api/v8/";
var result = await biz.RenderReport(reportParam.ReportId, reportParam.objectIdArray, API_URL);
var result = await biz.RenderReport(reportParam.ReportId, reportParam.ObjectIdArray, API_URL);
if (result == null)
return BadRequest(new ApiErrorResponse(biz.Errors));
else
@@ -193,7 +223,7 @@ namespace AyaNova.Api.Controllers
public class RenderReportParameter
{
public long ReportId { get; set; }
public long[] objectIdArray { get; set; }
public long[] ObjectIdArray { get; set; }
}