Bulk tag ops

This commit is contained in:
2020-05-16 00:12:36 +00:00
parent 1debeafbbd
commit d1fec5f415
3 changed files with 60 additions and 14 deletions

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
@@ -46,7 +47,7 @@ namespace AyaNova.Api.Controllers
/// <param name="query">The query to filter the returned list by</param>
/// <returns>Filtered list (maximum 25 items are returned for any query)</returns>
[HttpGet("list")]
public async Task<IActionResult> GetList([FromQuery]string query)
public async Task<IActionResult> GetList([FromQuery] string query)
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
@@ -59,7 +60,7 @@ namespace AyaNova.Api.Controllers
/// <param name="query">The query to filter the returned list by</param>
/// <returns>List</returns>
[HttpGet("cloudlist")]
public async Task<IActionResult> GetCloudList([FromQuery]string query)
public async Task<IActionResult> GetCloudList([FromQuery] string query)
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
@@ -67,6 +68,32 @@ namespace AyaNova.Api.Controllers
}
/////////////////////////////////
//BULK OPS
//
/// <summary>
/// Bulk add tags to objects
/// </summary>
/// <param name="ayaType">Required</param>
/// <param name="tagOpParams">Required</param>
/// <returns>Number of items affected</returns>
[HttpPost("bulk-add/{ayaType}")]
public async Task<IActionResult> BulkAdd([FromRoute] AyaType ayaType, [FromBody] TagUtil.BulkTagOpParameter tagOpParams)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
if (!Authorized.HasModifyRole(HttpContext.Items, ayaType))
return StatusCode(403, new ApiNotAuthorizedResponse());
return Ok(ApiOkResponse.Response(await TagUtil.BulkAdd(ayaType, tagOpParams, ct), true));
}
}//eoc
}//ens

View File

@@ -204,13 +204,31 @@ namespace AyaNova.Biz
.ToListAsync();
}
}
public class TagCloudItem
{
public long RefCount { get; set; }
public string Name { get; set; }
}
/////////////////////////////////
//BULK OPS
//
public static async Task<long> BulkAdd(AyaType ayaType, BulkTagOpParameter tagOpParams, AyContext ct)
{
throw new System.NotImplementedException("NOT IMPLEMENTED YET");
}
public class BulkTagOpParameter
{
public string NewTag { get; set; }
public List<long> ObjectIds { get; set; }
}
}//eoc
public class TagCloudItem
{
public long RefCount { get; set; }
public string Name { get; set; }
}
}//ens