This commit is contained in:
@@ -53,6 +53,7 @@ todo: api / server landing page is shitty on a mobile
|
|||||||
todo: Log configuration into server log at startup? https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3523
|
todo: Log configuration into server log at startup? https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3523
|
||||||
log all config settings into server log on boot
|
log all config settings into server log on boot
|
||||||
todo:aycontext clean up old block of weird definitions
|
todo:aycontext clean up old block of weird definitions
|
||||||
|
todo: apiokresponse returns readonly value every time, but I check it anyway at the client and biz object itself doesn't set it I don't think, so...should it be removed?
|
||||||
todo: Is there a log that records past jobs, how long can they be viewed?
|
todo: Is there a log that records past jobs, how long can they be viewed?
|
||||||
todo: Rename the link to AyaNova App on the server page to just "AyaNova"
|
todo: Rename the link to AyaNova App on the server page to just "AyaNova"
|
||||||
todo: translation cjkindex, no way to set this value currently
|
todo: translation cjkindex, no way to set this value currently
|
||||||
|
|||||||
@@ -101,17 +101,15 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the top level ancestor of provided type and id
|
/// Get the top level ancestor of provided type and id
|
||||||
/// (e.g. find the WorkOrder principle for a WorkOrderItemPart object descendent)
|
/// (e.g. find the WorkOrder principle for a WorkOrderItemPart object descendent)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ayaType"></param>
|
/// <param name="ayaType"></param>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="phrase"></param>
|
/// <returns>A type and id of ancestor</returns>
|
||||||
/// <param name="max"></param>
|
|
||||||
/// <returns>A search result excerpt of object</returns>
|
|
||||||
[HttpGet("ancestor/{ayaType}/{id}")]
|
[HttpGet("ancestor/{ayaType}/{id}")]
|
||||||
public async Task<IActionResult> GetAncestor([FromRoute] AyaType ayaType, [FromRoute] long id, [FromQuery] string phrase, [FromQuery] int max = 80)
|
public async Task<IActionResult> GetAncestor([FromRoute] AyaType ayaType, [FromRoute] long id)
|
||||||
{
|
{
|
||||||
if (serverState.IsClosed)
|
if (serverState.IsClosed)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
@@ -123,18 +121,32 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
switch (ayaType)
|
||||||
|
{
|
||||||
|
case AyaType.WorkOrderItem:
|
||||||
|
case AyaType.WorkOrderItemExpense:
|
||||||
|
case AyaType.WorkOrderItemLabor:
|
||||||
|
case AyaType.WorkOrderItemLoan:
|
||||||
|
case AyaType.WorkOrderItemPart:
|
||||||
|
case AyaType.WorkOrderItemPartRequest:
|
||||||
|
case AyaType.WorkOrderItemScheduledUser:
|
||||||
|
case AyaType.WorkOrderItemTask:
|
||||||
|
case AyaType.WorkOrderItemTravel:
|
||||||
|
return Ok(ApiOkResponse.Response(await WorkOrderBiz.GetAncestor(ayaType, id, ct), true));
|
||||||
|
default:
|
||||||
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, "ayaType", "Only types with ancestors are valid"));
|
||||||
|
|
||||||
//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),
|
// var res = await Search.GetInfoAsync(ct, UserTranslationIdFromContext.Id(HttpContext.Items),
|
||||||
// UserRolesFromContext.Roles(HttpContext.Items), UserIdFromContext.Id(HttpContext.Items), phrase, max, ayaType, id);
|
// UserRolesFromContext.Roles(HttpContext.Items), UserIdFromContext.Id(HttpContext.Items), phrase, max, ayaType, id);
|
||||||
|
|
||||||
return Ok(ApiOkResponse.Response(res, true));
|
return Ok(ApiOkResponse.Response(res, true));
|
||||||
}
|
}
|
||||||
//------------
|
//------------
|
||||||
|
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
}//eons
|
}//eons
|
||||||
@@ -252,6 +252,41 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// GET ANCESTOR
|
||||||
|
//
|
||||||
|
internal static async Task<AyaTypeId> GetAncestor(AyaType ayType, long id, AyContext ct)
|
||||||
|
{
|
||||||
|
//Note: there could be rules checking here in future, i.e. can only get own workorder or something
|
||||||
|
//if so, then need to implement AddError and in route handle Null return with Error check just like PUT route does now
|
||||||
|
|
||||||
|
//https://docs.microsoft.com/en-us/ef/core/querying/related-data
|
||||||
|
//docs say this will not query twice but will recognize the duplicate woitem bit which is required for multiple grandchild collections
|
||||||
|
var ret =
|
||||||
|
await ct.WorkOrder
|
||||||
|
.Include(w => w.Items)
|
||||||
|
.ThenInclude(wi => wi.Expenses)
|
||||||
|
.Include(w => w.Items)
|
||||||
|
.ThenInclude(wi => wi.Labors)
|
||||||
|
.Include(w => w.Items)
|
||||||
|
.ThenInclude(wi => wi.Loans)
|
||||||
|
.Include(w => w.Items)
|
||||||
|
.ThenInclude(wi => wi.Parts)
|
||||||
|
.Include(w => w.Items)
|
||||||
|
.ThenInclude(wi => wi.PartRequests)
|
||||||
|
.Include(w => w.Items)
|
||||||
|
.ThenInclude(wi => wi.ScheduledUsers)
|
||||||
|
.Include(w => w.Items)
|
||||||
|
.ThenInclude(wi => wi.Tasks)
|
||||||
|
.Include(w => w.Items)
|
||||||
|
.ThenInclude(wi => wi.Travels)
|
||||||
|
.Include(w => w.Items)
|
||||||
|
.ThenInclude(wi => wi.Units)
|
||||||
|
.SingleOrDefaultAsync(m => m.Id == id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private async Task WorkOrderSearchIndexAsync(WorkOrder obj, bool isNew)
|
private async Task WorkOrderSearchIndexAsync(WorkOrder obj, bool isNew)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user