This commit is contained in:
@@ -95,7 +95,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
tag = TagUtil.NormalizeTag(tag);
|
tag = TagUtil.NormalizeTag(tag);
|
||||||
if (string.IsNullOrWhiteSpace(tag))
|
if (string.IsNullOrWhiteSpace(tag))
|
||||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "tag"));
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "tag"));
|
||||||
var JobName = $"BulkAdd tag {tag} to {ayaType} ({idList.Count} specified)";
|
|
||||||
|
var JobName = $"BulkAdd tag \"{tag}\" to {ayaType} ({idList.Count} specified)";
|
||||||
JObject o = JObject.FromObject(new
|
JObject o = JObject.FromObject(new
|
||||||
{
|
{
|
||||||
ayaType = ayaType,
|
ayaType = ayaType,
|
||||||
@@ -110,7 +111,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
j.Exclusive = false;
|
j.Exclusive = false;
|
||||||
j.JobInfo = o.ToString();
|
j.JobInfo = o.ToString();
|
||||||
await JobsBiz.AddJobAsync(j, ct);
|
await JobsBiz.AddJobAsync(j, ct);
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, ayaType, AyaEvent.Created, JobName), ct);
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.ServerJob, AyaEvent.Created, JobName), ct);
|
||||||
return Accepted(new { JobId = j.GId });
|
return Accepted(new { JobId = j.GId });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +130,27 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
|
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
return Ok(ApiOkResponse.Response(await TagUtil.BulkAddAny(ayaType, tag, ct), true));
|
|
||||||
|
tag = TagUtil.NormalizeTag(tag);
|
||||||
|
if (string.IsNullOrWhiteSpace(tag))
|
||||||
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_REQUIRED, "tag"));
|
||||||
|
|
||||||
|
var JobName = $"BulkAdd tag \"{tag}\" to any {ayaType}";
|
||||||
|
JObject o = JObject.FromObject(new
|
||||||
|
{
|
||||||
|
ayaType = ayaType,
|
||||||
|
op = "bulk-add-any",
|
||||||
|
tag = tag
|
||||||
|
});
|
||||||
|
|
||||||
|
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>
|
||||||
@@ -148,7 +169,29 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
|
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
return Ok(ApiOkResponse.Response(await TagUtil.BulkRemove(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 = 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>
|
||||||
@@ -166,7 +209,29 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
|
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
return Ok(ApiOkResponse.Response(await TagUtil.BulkRemoveAny(ayaType, tag, 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 = 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>
|
||||||
@@ -186,7 +251,29 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
|
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
return Ok(ApiOkResponse.Response(await TagUtil.BulkReplace(ayaType, fromTag, toTag, 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 = 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>
|
||||||
@@ -205,7 +292,32 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
|
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
return Ok(ApiOkResponse.Response(await TagUtil.BulkReplaceAny(ayaType, fromTag, toTag, ct), true));
|
|
||||||
|
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 any {ayaType}";
|
||||||
|
JObject o = JObject.FromObject(new
|
||||||
|
{
|
||||||
|
ayaType = ayaType,
|
||||||
|
op = "bulk-replace-any",
|
||||||
|
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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user