This commit is contained in:
2020-05-16 15:32:53 +00:00
parent 36cc5fd825
commit 6f0182042e
3 changed files with 31 additions and 4 deletions

View File

@@ -7,6 +7,8 @@ using Microsoft.AspNetCore.Authorization;
using AyaNova.Models;
using AyaNova.Api.ControllerHelpers;
using AyaNova.Biz;
using Newtonsoft.Json.Linq;
namespace AyaNova.Api.Controllers
@@ -88,7 +90,30 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState));
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
return StatusCode(403, new ApiNotAuthorizedResponse());
return Ok(ApiOkResponse.Response(await TagUtil.BulkAdd(ayaType, tag, idList, ct), true));
if (idList.Count == 0)
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "List of ids"));
tag = TagUtil.NormalizeTag(tag);
if (string.IsNullOrWhiteSpace(tag))
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "tag"));
var JobName = $"BulkAdd tag {tag} to {ayaType} ({idList.Count} specified)";
JObject o = JObject.FromObject(new
{
ayaType = ayaType,
idList = idList,
op = "bulk-add",
tag = tag
});
OpsJob j = new OpsJob();
j.Name = $"BulkTag";
j.JobType = JobType.BulkTag;
j.Exclusive = false;
j.JobInfo = o.ToString();
// await JobsBiz.AddJobAsync(j, ct);
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, ayaType, AyaEvent.Created, JobName), ct);
return Accepted(new { JobId = j.GId });
}
/// <summary>