feat(api): SyncTaskController, обновлен метод для отправки задания в matcher. Теперь метод универсальный.
This commit is contained in:
@@ -492,12 +492,16 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SyncTask
|
#region SyncTask
|
||||||
|
|
||||||
public static class SyncTask
|
public static class SyncTask
|
||||||
{
|
{
|
||||||
public const string MatchTemplatesForJob = Base + "/sync-tasks/jobs/{jobId}/match-templates";
|
public const string MatchTemplates = Base + "/sync-tasks/match-templates";
|
||||||
public const string MatchTemplatesForJobGroup = Base + "/sync-tasks/job-groups/{jobGroupId}/match-templates";
|
|
||||||
public const string MatchTemplatesForTemplate = Base + "/sync-tasks/templates/{templateId}/match-templates";
|
//public const string MatchTemplatesForJob = Base + "/sync-tasks/jobs/{jobId}/match-templates";
|
||||||
|
//public const string MatchTemplatesForJobGroup = Base + "/sync-tasks/job-groups/{jobGroupId}/match-templates";
|
||||||
|
//public const string MatchTemplatesForTemplate = Base + "/sync-tasks/templates/{templateId}/match-templates";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
using PARR.Constants;
|
|
||||||
|
|
||||||
namespace PARR.API.Contracts.V1.Requests
|
|
||||||
{
|
|
||||||
public class MatchTemplatesForJobRequest
|
|
||||||
{
|
|
||||||
public TemplateMatcherActionEnum Action { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
13
PARR.API/Contracts/V1/Requests/MatchTemplatesRequest.cs
Normal file
13
PARR.API/Contracts/V1/Requests/MatchTemplatesRequest.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using PARR.Constants;
|
||||||
|
|
||||||
|
namespace PARR.API.Contracts.V1.Requests
|
||||||
|
{
|
||||||
|
public class MatchTemplatesRequest
|
||||||
|
{
|
||||||
|
public Guid ObjectId { get; set; }
|
||||||
|
|
||||||
|
public SyncTaskEntityTypeEnum EntityType { get; set; }
|
||||||
|
|
||||||
|
public TemplateMatcherActionEnum Action { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ using PARR.API.Contracts.V1;
|
|||||||
using PARR.API.Contracts.V1.Requests;
|
using PARR.API.Contracts.V1.Requests;
|
||||||
using PARR.API.Contracts.V1.Responses.Base;
|
using PARR.API.Contracts.V1.Responses.Base;
|
||||||
using PARR.API.Controllers.V1.Base;
|
using PARR.API.Controllers.V1.Base;
|
||||||
using PARR.API.Services.Implementations;
|
|
||||||
using PARR.API.Services.Interfaces;
|
using PARR.API.Services.Interfaces;
|
||||||
using PARR.API.Settings;
|
using PARR.API.Settings;
|
||||||
using PARR.BLL.Domain.Mq;
|
using PARR.BLL.Domain.Mq;
|
||||||
@@ -38,22 +37,26 @@ namespace PARR.API.Controllers.V1
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сопоставить текущие шаблоны для Job, создать недостущие шаблоны
|
/// Отправить задание в Matcher
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpPost(ApiRoutes.SyncTask.MatchTemplatesForJob)]
|
[HttpPost(ApiRoutes.SyncTask.MatchTemplates)]
|
||||||
public async Task<IActionResult> MatchTemplatesForJob([FromRoute] Guid jobId, [FromBody] MatchTemplatesForJobRequest request)
|
public async Task<IActionResult> MatchTemplatesForJob([FromBody] MatchTemplatesRequest request)
|
||||||
{
|
{
|
||||||
|
//todo: Валидатор! Валидатор то забыли!!!
|
||||||
|
|
||||||
|
|
||||||
//24b3529a-dd43-444a-b10e-ac54fefd046a
|
//24b3529a-dd43-444a-b10e-ac54fefd046a
|
||||||
var matchTemplateTask = new TemplateMatcherMq
|
var matchTemplateTask = new TemplateMatcherMq
|
||||||
{
|
{
|
||||||
Id = jobId,
|
Id = request.ObjectId,
|
||||||
EntityType = Constants.SyncTaskEntityTypeEnum.Job,
|
// EntityType = Constants.SyncTaskEntityTypeEnum.Job,
|
||||||
|
EntityType = request.EntityType,
|
||||||
Action = request.Action,
|
Action = request.Action,
|
||||||
Initiator = new HistoryInitiator
|
Initiator = new HistoryInitiator
|
||||||
{
|
{
|
||||||
InitiatorIp = clientService.GetClientIp()?.ToString(),
|
InitiatorIp = clientService.GetClientIp()?.ToString(),
|
||||||
InitiatorParrComponentId = ParrComponentsEnum.Api,
|
InitiatorParrComponentId = ParrComponentsEnum.Api,
|
||||||
InitiatorComment = $"Отправлен запрос из GUI, action: {request.Action.ToString()}"
|
InitiatorComment = $"Отправлен запрос из GUI, action: {request.Action.ToString()}, entityType: {request.EntityType.ToString()}"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,9 +69,9 @@ namespace PARR.API.Controllers.V1
|
|||||||
if (!result.IsSuccess)
|
if (!result.IsSuccess)
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка отправки сообщения в очередь" } }));
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка отправки сообщения в очередь" } }));
|
||||||
|
|
||||||
var createdUri = uriService.GetAllUri(ApiRoutes.SyncTask.MatchTemplatesForJob);
|
//var createdUri = uriService.GetAllUri(ApiRoutes.SyncTask.MatchTemplatesForJob);
|
||||||
|
|
||||||
return Created(createdUri, new Response<string?>(null, true, new List<ErrorModel>(), "Отправлен запрос на сопоставление шаблонов и Job"));
|
return Created("", new Response<string?>(null, true, new List<ErrorModel>(), "Отправлен запрос на сопоставление шаблонов"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user