This commit is contained in:
2020-05-15 20:30:58 +00:00
parent 8c30d26b42
commit 87437f60de
2 changed files with 38 additions and 3 deletions

View File

@@ -17,9 +17,9 @@ todo: Search get search result for workorder descendents doesn't fit into existi
In Client, navigating to exact item e.g. a workorder item part is a client ui issue really
The only issue related to the server is getting the top most parent openable object, the workorder in this case
the rest can be done at the client easily
Add route: ancestor(ayatype, ayaid) returns type and id, if no higher ancestor returns what came in
Add Search controller route: ancestor(ayatype, ayaid) returns type and id, if no higher ancestor returns what came in
this needs to be a central route, not tied to an object though objects can handle the inner workings maybe i.e. wokorderbiz for workorder tree , pobiz for po tree etc
todo: search tables in schema, I think there is a missing index here, need to look at the search query section again as it was changed several times from the original schema creation
todo: schema, move all initializing stuff to schema update 1
@@ -45,7 +45,8 @@ todo: REMOVE TAGS
route: mass remove specified tag by type and id collection
route: mass remove tag by type and all objects no id specified
todo: API root controller
build mode and server info should be authorized shoudln't they? Unauthorized people have no need to see that stuff
todo: api / server landing page is shitty on a mobile
and really just shitty, add a logo or some shit
todo: Should server show uptime somewhere?

View File

@@ -99,6 +99,40 @@ namespace AyaNova.Api.Controllers
return Ok(ApiOkResponse.Response(res, true));
}
/// <summary>
/// Get the top level ancestor of provided type and id
/// (e.g. find the WorkOrder principle for a WorkOrderItemPart object descendent)
/// </summary>
/// <param name="ayaType"></param>
/// <param name="id"></param>
/// <param name="phrase"></param>
/// <param name="max"></param>
/// <returns>A search result excerpt of object</returns>
[HttpGet("ancestor/{ayaType}/{id}")]
public async Task<IActionResult> GetAncestor([FromRoute] AyaType ayaType, [FromRoute] long id, [FromQuery] string phrase, [FromQuery] int max = 80)
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasReadFullRole(HttpContext.Items, ayaType))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
if (id == 0)
return NotFound();
//pawn this off to biz object static methods as appropriate
//if not in this list of types then it has no ancestor so just return the same values back
//or, maybe just fail code so people don't think they should run every object through here when they want to open it foolishly / needlessly / ignorantely
// var res = await Search.GetInfoAsync(ct, UserTranslationIdFromContext.Id(HttpContext.Items),
// UserRolesFromContext.Roles(HttpContext.Items), UserIdFromContext.Id(HttpContext.Items), phrase, max, ayaType, id);
return Ok(ApiOkResponse.Response(res, true));
}
//------------