This commit is contained in:
@@ -14,6 +14,7 @@ Clean up AyaObjectField definition for FORM FIELD STUFF:
|
|||||||
Extracted from ayaobjectfielddefinitions
|
Extracted from ayaobjectfielddefinitions
|
||||||
Essentially the same thing as it is now, so maybe just rename the existing one
|
Essentially the same thing as it is now, so maybe just rename the existing one
|
||||||
|
|
||||||
|
Rename objectfieldscontroller / routes
|
||||||
|
|
||||||
MAKE DATALIST ROUTE FOR FETCHING LISTS BY KEY
|
MAKE DATALIST ROUTE FOR FETCHING LISTS BY KEY
|
||||||
- REMOVE LISTS FROM INDIVIDUAL OBJECT ROUTES AS MUCH AS POSSIBLE
|
- REMOVE LISTS FROM INDIVIDUAL OBJECT ROUTES AS MUCH AS POSSIBLE
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ namespace AyaNova.Api.Controllers
|
|||||||
[Route("api/v{version:apiVersion}/[controller]")]
|
[Route("api/v{version:apiVersion}/[controller]")]
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class DataFilterController : ControllerBase
|
public class DataListFilterController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly AyContext ct;
|
private readonly AyContext ct;
|
||||||
private readonly ILogger<DataFilterController> log;
|
private readonly ILogger<DataListFilterController> log;
|
||||||
private readonly ApiServerState serverState;
|
private readonly ApiServerState serverState;
|
||||||
|
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// <param name="dbcontext"></param>
|
/// <param name="dbcontext"></param>
|
||||||
/// <param name="logger"></param>
|
/// <param name="logger"></param>
|
||||||
/// <param name="apiServerState"></param>
|
/// <param name="apiServerState"></param>
|
||||||
public DataFilterController(AyContext dbcontext, ILogger<DataFilterController> logger, ApiServerState apiServerState)
|
public DataListFilterController(AyContext dbcontext, ILogger<DataListFilterController> logger, ApiServerState apiServerState)
|
||||||
{
|
{
|
||||||
ct = dbcontext;
|
ct = dbcontext;
|
||||||
log = logger;
|
log = logger;
|
||||||
@@ -60,7 +60,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
DataFilterBiz biz = DataFilterBiz.GetBiz(ct, HttpContext);
|
DataListFilterBiz biz = DataListFilterBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
@@ -94,7 +94,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
DataFilterBiz biz = DataFilterBiz.GetBiz(ct, HttpContext);
|
DataListFilterBiz biz = DataListFilterBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
var l = await biz.GetPickListAsync(ListKey);
|
var l = await biz.GetPickListAsync(ListKey);
|
||||||
return Ok(ApiOkResponse.Response(l, true));
|
return Ok(ApiOkResponse.Response(l, true));
|
||||||
@@ -122,7 +122,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
DataFilterBiz biz = DataFilterBiz.GetBiz(ct, HttpContext);
|
DataListFilterBiz biz = DataListFilterBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
var o = await biz.GetNoLogAsync(id);
|
var o = await biz.GetNoLogAsync(id);
|
||||||
if (o == null)
|
if (o == null)
|
||||||
@@ -163,7 +163,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
DataFilterBiz biz = DataFilterBiz.GetBiz(ct, HttpContext);
|
DataListFilterBiz biz = DataListFilterBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
//If a user has change roles, or editOwnRoles then they can create, true is passed for isOwner since they are creating so by definition the owner
|
//If a user has change roles, or editOwnRoles then they can create, true is passed for isOwner since they are creating so by definition the owner
|
||||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||||
@@ -177,7 +177,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
if (o == null)
|
if (o == null)
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
else
|
else
|
||||||
return CreatedAtAction(nameof(DataFilterController.GetDataFilter), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
return CreatedAtAction(nameof(DataListFilterController.GetDataFilter), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
DataFilterBiz biz = DataFilterBiz.GetBiz(ct, HttpContext);
|
DataListFilterBiz biz = DataListFilterBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
var o = await biz.GetNoLogAsync(id);
|
var o = await biz.GetNoLogAsync(id);
|
||||||
if (o == null)
|
if (o == null)
|
||||||
@@ -121,16 +121,16 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public static string TranslateLTCustomFieldToInternalCustomFieldName(string lTCustomFieldName)
|
public static string TranslateLTCustomFieldToInternalCustomFieldName(string lTCustomFieldName)
|
||||||
// {
|
{
|
||||||
// var i = System.Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(
|
var i = System.Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(
|
||||||
// lTCustomFieldName, // Our input
|
lTCustomFieldName, // Our input
|
||||||
// "[^0-9]", // Select everything that is not in the range of 0-9
|
"[^0-9]", // Select everything that is not in the range of 0-9
|
||||||
// "" // Replace that with an empty string.
|
"" // Replace that with an empty string.
|
||||||
// ));
|
));
|
||||||
|
|
||||||
// return $"c{i}";
|
return $"c{i}";
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace AyaNova.Biz
|
|||||||
case AyaType.Locale:
|
case AyaType.Locale:
|
||||||
return new LocaleBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
|
return new LocaleBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
|
||||||
case AyaType.DataFilter:
|
case AyaType.DataFilter:
|
||||||
return new DataFilterBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
|
return new DataListFilterBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
|
||||||
case AyaType.FormCustom:
|
case AyaType.FormCustom:
|
||||||
return new FormCustomBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
|
return new FormCustomBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,17 @@ using Newtonsoft.Json.Linq;
|
|||||||
using AyaNova.Util;
|
using AyaNova.Util;
|
||||||
using AyaNova.Api.ControllerHelpers;
|
using AyaNova.Api.ControllerHelpers;
|
||||||
using AyaNova.Models;
|
using AyaNova.Models;
|
||||||
|
using AyaNova.DataList;
|
||||||
|
|
||||||
|
|
||||||
namespace AyaNova.Biz
|
namespace AyaNova.Biz
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
internal class DataFilterBiz : BizObject
|
internal class DataListFilterBiz : BizObject
|
||||||
{
|
{
|
||||||
|
|
||||||
internal DataFilterBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles)
|
internal DataListFilterBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles)
|
||||||
{
|
{
|
||||||
ct = dbcontext;
|
ct = dbcontext;
|
||||||
UserId = currentUserId;
|
UserId = currentUserId;
|
||||||
@@ -24,15 +25,15 @@ namespace AyaNova.Biz
|
|||||||
BizType = AyaType.DataFilter;
|
BizType = AyaType.DataFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static DataFilterBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)
|
internal static DataListFilterBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)
|
||||||
{
|
{
|
||||||
return new DataFilterBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
|
return new DataListFilterBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Version for internal use
|
//Version for internal use
|
||||||
internal static DataFilterBiz GetBizInternal(AyContext ct)
|
internal static DataListFilterBiz GetBizInternal(AyContext ct)
|
||||||
{
|
{
|
||||||
return new DataFilterBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull);
|
return new DataListFilterBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -247,15 +248,17 @@ namespace AyaNova.Biz
|
|||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "ListKey");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "ListKey");
|
||||||
|
|
||||||
|
|
||||||
List<AyaFormFieldDefinition> FieldList = null;
|
var DataList = DataListFactory.GetAyaDataList(inObj.ListKey);
|
||||||
if (!AyaFormFieldDefinitions.IsValidFormFieldDefinitionKey(inObj.ListKey))
|
// List<AyaDataListFieldDefinition> FieldList = null;
|
||||||
|
//if (!AyaFormFieldDefinitions.IsValidFormFieldDefinitionKey(inObj.ListKey))
|
||||||
|
if (DataList == null)
|
||||||
{
|
{
|
||||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "ListKey", $"ListKey \"{inObj.ListKey}\" is empty or in-valid");
|
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "ListKey", $"ListKey \"{inObj.ListKey}\" DataListKey is not valid");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FieldList = AyaFormFieldDefinitions.AyaObjectFields(inObj.ListKey);
|
|
||||||
}
|
}
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// FieldList = AyaDataListFieldDefinition.AyaObjectFields(inObj.ListKey);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
if (inObj.ListKey.Length > 255)
|
if (inObj.ListKey.Length > 255)
|
||||||
@@ -279,10 +282,10 @@ namespace AyaNova.Biz
|
|||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Filter", $"Filter array item {i}, \"fld\" property is empty and required");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Filter", $"Filter array item {i}, \"fld\" property is empty and required");
|
||||||
|
|
||||||
//validate the field name if we can
|
//validate the field name if we can
|
||||||
if (FieldList != null)
|
if (DataList != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
var TheField = FieldList.SingleOrDefault(x => x.FieldKey.ToLowerInvariant() == fld);
|
var TheField = DataList.FieldDefinitions.SingleOrDefault(x => x.FieldKey.ToLowerInvariant() == fld);
|
||||||
|
|
||||||
if (TheField == null)
|
if (TheField == null)
|
||||||
{
|
{
|
||||||
@@ -348,10 +351,10 @@ namespace AyaNova.Biz
|
|||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Sort", $"Sort array item {i}, \"fld\" property is empty and required");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Sort", $"Sort array item {i}, \"fld\" property is empty and required");
|
||||||
|
|
||||||
//validate the field name if we can
|
//validate the field name if we can
|
||||||
if (FieldList != null)
|
if (DataList != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!FieldList.Exists(x => x.FieldKey.ToLowerInvariant() == fld && x.IsFilterable))
|
if (!DataList.FieldDefinitions.Exists(x => x.FieldKey.ToLowerInvariant() == fld && x.IsFilterable))
|
||||||
{
|
{
|
||||||
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Sort", $"Sort array item {i}, fld property value \"{fld}\" is not a valid value for ListKey specified");
|
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Sort", $"Sort array item {i}, fld property value \"{fld}\" is not a valid value for ListKey specified");
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user