This commit is contained in:
@@ -200,6 +200,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return Accepted(new { JobId = j.GId });
|
return Accepted(new { JobId = j.GId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bulk remove tags to all objects of type specified
|
/// Bulk remove tags to all objects of type specified
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -240,6 +241,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return Accepted(new { JobId = j.GId });
|
return Accepted(new { JobId = j.GId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bulk replace tags to list of object id's specified
|
/// Bulk replace tags to list of object id's specified
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -251,7 +253,40 @@ namespace AyaNova.Api.Controllers
|
|||||||
[HttpPost("bulk-replace/{ayaType}/{tag}")]
|
[HttpPost("bulk-replace/{ayaType}/{tag}")]
|
||||||
public async Task<IActionResult> BulkReplace([FromRoute] AyaType ayaType, [FromRoute] string fromTag, [FromQuery] string toTag, [FromBody] List<long> idList)
|
public async Task<IActionResult> BulkReplace([FromRoute] AyaType ayaType, [FromRoute] string fromTag, [FromQuery] string toTag, [FromBody] List<long> idList)
|
||||||
{
|
{
|
||||||
|
if (!serverState.IsOpen)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
if (!ayaType.HasAttribute(typeof(CoreBizObjectAttribute)))
|
||||||
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "ayaType", "Not a taggable object type"));
|
||||||
|
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
|
||||||
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
if (idList.Count == 0)
|
||||||
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "List of ids"));
|
||||||
|
fromTag = TagUtil.NormalizeTag(fromTag);
|
||||||
|
if (string.IsNullOrWhiteSpace(fromTag))
|
||||||
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "fromTag"));
|
||||||
|
toTag = TagUtil.NormalizeTag(toTag);
|
||||||
|
if (string.IsNullOrWhiteSpace(toTag))
|
||||||
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "toTag"));
|
||||||
|
var JobName = $"BulkReplace tag \"{fromTag}\" with tag \"{toTag}\" to {ayaType} ({idList.Count} specified)";
|
||||||
|
JObject o = JObject.FromObject(new
|
||||||
|
{
|
||||||
|
ayaType = ayaType,
|
||||||
|
idList = idList,
|
||||||
|
op = "bulk-replace",
|
||||||
|
fromTag = fromTag,
|
||||||
|
toTag = toTag
|
||||||
|
});
|
||||||
|
|
||||||
|
OpsJob j = new OpsJob();
|
||||||
|
j.Name = JobName;
|
||||||
|
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.ServerJob, AyaEvent.Created, JobName), ct);
|
||||||
|
return Accepted(new { JobId = j.GId });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user