Compare commits
8 Commits
e1a97514af
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37b9888532 | ||
| 6ec76fc975 | |||
| 1c193b68bb | |||
|
|
d4d0a4d2d1 | ||
| cf957eb3e0 | |||
| bed3202892 | |||
| 6826319089 | |||
|
|
b4fbee2989 |
12
.dockerignore
Normal file
12
.dockerignore
Normal file
@@ -0,0 +1,12 @@
|
||||
**/bin
|
||||
**/obj
|
||||
**/out
|
||||
**/.vs
|
||||
**/.idea
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/node_modules
|
||||
*.user
|
||||
*.swp
|
||||
*.swo
|
||||
.DS_Store
|
||||
@@ -171,6 +171,15 @@ namespace Core.Inventory.BFF.API.Controllers
|
||||
/// <summary>
|
||||
/// Changes the status of the Product.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the product ID and new ProductStatus.</param>
|
||||
/// <returns>The <see cref="ProductAdapter"/> updated entity.</returns>
|
||||
/// <response code="200">The Product updates.</response>
|
||||
/// <response code="204">The Product not found.</response>
|
||||
/// <response code="400">The Product could not be updated.</response>
|
||||
/// <response code="401">The Product could not be updated.</response>
|
||||
/// <response code="412">The Product could not be updated.</response>
|
||||
/// <response code="422">The Product could not be updated.</response>
|
||||
/// <response code="500">The service internal error.</response>
|
||||
[HttpPatch]
|
||||
[Route("ChangeStatus")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@@ -256,5 +265,43 @@ namespace Core.Inventory.BFF.API.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a Product by its identifier.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the product ID to delete.</param>
|
||||
/// <param name="cancellationToken">Cancellation token for the asynchronous operation.</param>
|
||||
/// <returns>The <see cref="IActionResult"/> representing the result of the service call.</returns>
|
||||
/// <response code="200">The Product deleted successfully.</response>
|
||||
/// <response code="204">No content if the Product was not found.</response>
|
||||
/// <response code="400">Bad request if the Product ID is missing or invalid.</response>
|
||||
/// <response code="401">Unauthorized if the user is not authenticated.</response>
|
||||
/// <response code="412">Precondition failed if the request does not meet expected conditions.</response>
|
||||
/// <response code="422">Unprocessable entity if the request cannot be processed.</response>
|
||||
/// <response code="500">Internal server error if an unexpected error occurs.</response>
|
||||
[HttpDelete("Delete")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> DeleteProductService([FromBody] DeleteProductRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(DeleteProductService)} - Request received - Payload: {JsonSerializer.Serialize(request)}");
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid Product identifier"); }
|
||||
|
||||
return await Handle(() => inventoryServiceClient.DeleteProductService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError($"{nameof(DeleteProductService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using Core.Adapters.Lib;
|
||||
using Core.Inventory.External.Clients.Inventory;
|
||||
using Core.Inventory.External.Clients.Inventory.Requests.Tag;
|
||||
using Core.Inventory.External.Clients.Inventory.Requests.TagType;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -150,21 +151,21 @@ namespace Core.Inventory.BFF.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> UpdateTagService(UpdateTagRequest newTag, CancellationToken cancellationToken)
|
||||
public async Task<IActionResult> UpdateTagService(UpdateTagRequest tag, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(UpdateTagService)} - Request received - Payload: {JsonSerializer.Serialize(newTag)}");
|
||||
logger.LogInformation($"{nameof(UpdateTagService)} - Request received - Payload: {JsonSerializer.Serialize(tag)}");
|
||||
|
||||
if (newTag == null) return BadRequest("Invalid Tag object");
|
||||
if (tag == null) return BadRequest("Invalid Tag object");
|
||||
|
||||
if (string.IsNullOrEmpty(newTag.TagName)) return BadRequest("Invalid Tag name");
|
||||
if (string.IsNullOrEmpty(tag.TagName)) return BadRequest("Invalid Tag name");
|
||||
|
||||
return await Handle(() => inventoryServiceClient.UpdateTagService(newTag, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => inventoryServiceClient.UpdateTagService(tag, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError($"{nameof(UpdateTagService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(newTag)}");
|
||||
logger.LogError($"{nameof(UpdateTagService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(tag)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -257,5 +258,34 @@ namespace Core.Inventory.BFF.API.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a full Tag by identifier.
|
||||
/// </summary>
|
||||
[HttpDelete("Delete")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> DeleteTagService(DeleteTagRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(DeleteTagService)} - Request received - Payload: {JsonSerializer.Serialize(request)}");
|
||||
|
||||
if (request == null) return BadRequest("Invalid Tag object");
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid Tag identifier");
|
||||
|
||||
return await Handle(() => inventoryServiceClient.DeleteTagService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError($"{nameof(DeleteTagService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
235
Core.Inventory.BFF.API/Controllers/TagOverrideController.cs
Normal file
235
Core.Inventory.BFF.API/Controllers/TagOverrideController.cs
Normal file
@@ -0,0 +1,235 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Adapters.Lib;
|
||||
using Core.Inventory.External.Clients.Inventory;
|
||||
using Core.Inventory.External.Clients.Inventory.Requests.TagOverride;
|
||||
using Core.Inventory.External.Clients.Inventory.Requests.TagType;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Core.Inventory.BFF.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all requests for TagOverride authentication.
|
||||
/// </summary>
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
[Consumes("application/json")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
[AllowAnonymous]
|
||||
public class TagOverrideController(IInventoryServiceClient inventoryServiceClient, ILogger<TagOverrideController> logger) : BaseController(logger)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets all the TagOverrides.
|
||||
/// </summary>
|
||||
[HttpGet("GetAll")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetAllTagOverridesService(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(GetAllTagOverridesService)} - Request received - Payload: ");
|
||||
|
||||
return await Handle(() => inventoryServiceClient.GetAllTagOverridesService(new GetAllTagOverridesRequest { }, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError($"{nameof(GetAllTagOverridesService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the TagOverrides by TagOverride identifiers.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the list of TagOverride identifiers.</param>
|
||||
/// <param name="cancellationToken">Cancellation token for the asynchronous operation.</param>
|
||||
/// <returns>The <see cref="IActionResult"/> representing the result of the service call.</returns>
|
||||
/// <response code="200">The TagOverrides found.</response>
|
||||
/// <response code="204">No content if no TagOverrides are found.</response>
|
||||
/// <response code="400">Bad request if the TagOverride identifiers are missing or invalid.</response>
|
||||
/// <response code="401">Unauthorized if the user is not authenticated.</response>
|
||||
/// <response code="500">Internal server error if an unexpected error occurs.</response>
|
||||
[HttpPost("GetAllByList")]
|
||||
[ProducesResponseType(typeof(IEnumerable<TagOverrideAdapter>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetAllTagOverridesByListAsync([FromBody] GetAllTagOverridesByListRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(GetAllTagOverridesByListAsync)} - Request received - Payload: {request}");
|
||||
|
||||
if (request == null || request.TagOverrides == null || !request.TagOverrides.Any())
|
||||
{
|
||||
return BadRequest("TagOverride identifiers are required.");
|
||||
}
|
||||
|
||||
return await Handle(() => inventoryServiceClient.GetAllTagOverridesByListService(request, cancellationToken)).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, $"{nameof(GetAllTagOverridesByListAsync)} - An error occurred - {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload: {request}");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "Internal server error");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new TagOverride.
|
||||
/// </summary>
|
||||
[HttpPost("Create")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> CreateTagOverrideService(CreateTagOverrideRequest newTagOverride, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(CreateTagOverrideService)} - Request received - Payload: {JsonSerializer.Serialize(newTagOverride)}");
|
||||
|
||||
if (newTagOverride == null) return BadRequest("Invalid TagOverride object");
|
||||
|
||||
if (string.IsNullOrEmpty(newTagOverride.BaseTagId)) return BadRequest("Invalid TagOverride BaseTagId");
|
||||
|
||||
if (string.IsNullOrEmpty(newTagOverride.OverrideTagId)) return BadRequest("Invalid TagOverride OverrideTagId");
|
||||
|
||||
return await Handle(() => inventoryServiceClient.CreateTagOverrideService(newTagOverride, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError($"{nameof(CreateTagOverrideService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(newTagOverride)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the TagOverride by identifier.
|
||||
/// </summary>
|
||||
[HttpPost("GetById")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetTagOverrideByIdService(GetTagOverrideRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(GetTagOverrideByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}");
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid TagOverride identifier");
|
||||
|
||||
return await Handle(() => inventoryServiceClient.GetTagOverrideByIdService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError($"{nameof(GetTagOverrideByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a full TagOverride by identifier.
|
||||
/// </summary>
|
||||
[HttpPut("Update")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> UpdateTagOverrideService(UpdateTagOverrideRequest tagOverride, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(UpdateTagOverrideService)} - Request received - Payload: {JsonSerializer.Serialize(tagOverride)}");
|
||||
|
||||
if (tagOverride == null) return BadRequest("Invalid TagOverride object");
|
||||
|
||||
if (string.IsNullOrEmpty(tagOverride.BaseTagId)) return BadRequest("Invalid TagOverride BaseTagId");
|
||||
|
||||
if (string.IsNullOrEmpty(tagOverride.OverrideTagId)) return BadRequest("Invalid TagOverride OverrideTagId");
|
||||
|
||||
return await Handle(() => inventoryServiceClient.UpdateTagOverrideService(tagOverride, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError($"{nameof(UpdateTagOverrideService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(tagOverride)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the status of the TagOverride.
|
||||
/// </summary>
|
||||
[HttpPatch]
|
||||
[Route("ChangeStatus")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> ChangeTagOverrideStatusService([FromBody] ChangeTagOverrideStatusRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(ChangeTagOverrideStatusService)} - Request received - Payload: {JsonSerializer.Serialize(request)}");
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid TagOverride identifier"); }
|
||||
|
||||
return await Handle(() => inventoryServiceClient.ChangeTagOverrideStatusService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError($"{nameof(ChangeTagOverrideStatusService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a full TagOverride by identifier.
|
||||
/// </summary>
|
||||
[HttpDelete("Delete")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> DeleteTagOverrideService(DeleteTagOverrideRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(DeleteTagOverrideService)} - Request received - Payload: {JsonSerializer.Serialize(request)}");
|
||||
|
||||
if (request == null) return BadRequest("Invalid TagOverride object");
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid TagOverride identifier");
|
||||
|
||||
return await Handle(() => inventoryServiceClient.DeleteTagOverrideService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError($"{nameof(DeleteTagOverrideService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,21 +150,21 @@ namespace Core.Inventory.BFF.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> UpdateTagTypeService(UpdateTagTypeRequest newTagType, CancellationToken cancellationToken)
|
||||
public async Task<IActionResult> UpdateTagTypeService(UpdateTagTypeRequest tagType, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(UpdateTagTypeService)} - Request received - Payload: {JsonSerializer.Serialize(newTagType)}");
|
||||
logger.LogInformation($"{nameof(UpdateTagTypeService)} - Request received - Payload: {JsonSerializer.Serialize(tagType)}");
|
||||
|
||||
if (newTagType == null) return BadRequest("Invalid TagType object");
|
||||
if (tagType == null) return BadRequest("Invalid TagType object");
|
||||
|
||||
if (string.IsNullOrEmpty(newTagType.TypeName)) return BadRequest("Invalid TagType name");
|
||||
if (string.IsNullOrEmpty(tagType.TypeName)) return BadRequest("Invalid TagType name");
|
||||
|
||||
return await Handle(() => inventoryServiceClient.UpdateTagTypeService(newTagType, cancellationToken)).ConfigureAwait(false);
|
||||
return await Handle(() => inventoryServiceClient.UpdateTagTypeService(tagType, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError($"{nameof(UpdateTagTypeService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(newTagType)}");
|
||||
logger.LogError($"{nameof(UpdateTagTypeService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(tagType)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -198,6 +198,33 @@ namespace Core.Inventory.BFF.API.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a full TagType by identifier.
|
||||
/// </summary>
|
||||
[HttpDelete("Delete")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> DeleteTagTypeService(DeleteTagTypeRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"{nameof(DeleteTagTypeService)} - Request received - Payload: {JsonSerializer.Serialize(request)}");
|
||||
|
||||
if (request == null) return BadRequest("Invalid TagType object");
|
||||
|
||||
if (string.IsNullOrEmpty(request.Id)) return BadRequest("Invalid TagType identifier");
|
||||
|
||||
return await Handle(() => inventoryServiceClient.DeleteTagTypeService(request, cancellationToken)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError($"{nameof(DeleteTagTypeService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
|
||||
<PackageReference Include="Core.Blueprint.Logging" Version="1.0.1" />
|
||||
<PackageReference Include="Core.Blueprint.Logging" Version="1.0.0" />
|
||||
<PackageReference Include="OpenTelemetry" Version="1.12.0" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.12.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.4" />
|
||||
|
||||
@@ -3,6 +3,7 @@ using Core.Adapters.Lib.Inventory;
|
||||
using Core.Inventory.External.Clients.Inventory.Requests.Base;
|
||||
using Core.Inventory.External.Clients.Inventory.Requests.Product;
|
||||
using Core.Inventory.External.Clients.Inventory.Requests.Tag;
|
||||
using Core.Inventory.External.Clients.Inventory.Requests.TagOverride;
|
||||
using Core.Inventory.External.Clients.Inventory.Requests.TagType;
|
||||
using Core.Inventory.External.Clients.Inventory.Requests.Variant;
|
||||
using Refit;
|
||||
@@ -75,6 +76,9 @@ namespace Core.Inventory.External.Clients.Inventory
|
||||
[Patch("/api/v1/TagType/ChangeStatus")]
|
||||
Task<ApiResponse<TagTypeAdapter>> ChangeTagTypeStatusService([Header("TrackingId")][Body] ChangeTagTypeStatusRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/api/v1/TagType/Delete")]
|
||||
Task<ApiResponse<TagTypeAdapter>> DeleteTagTypeService([Header("TrackingId")][Body] DeleteTagTypeRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tag
|
||||
@@ -103,6 +107,34 @@ namespace Core.Inventory.External.Clients.Inventory
|
||||
[Delete("/api/v1/Tag/RemoveParentTag")]
|
||||
Task<ApiResponse<TagAdapter>> RemoveParentTagAsync([Header("TrackingId")][Body] RemoveParentTagFromTag request, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/api/v1/Tag/Delete")]
|
||||
Task<ApiResponse<TagAdapter>> DeleteTagService([Header("TrackingId")][Body] DeleteTagRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
|
||||
#region TagOverride
|
||||
|
||||
[Post("/api/v1/TagOverride/Create")]
|
||||
Task<ApiResponse<TagOverrideAdapter>> CreateTagOverrideService([Header("TrackingId")][Body] CreateTagOverrideRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
[Post("/api/v1/TagOverride/GetById")]
|
||||
Task<ApiResponse<TagOverrideAdapter>> GetTagOverrideByIdService([Header("TrackingId")][Body] GetTagOverrideRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/api/v1/TagOverride/GetAll")]
|
||||
Task<ApiResponse<IEnumerable<TagOverrideAdapter>>> GetAllTagOverridesService([Header("TrackingId")][Body] GetAllTagOverridesRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
[Post("/api/v1/TagOverride/GetTagOverrideList")]
|
||||
Task<ApiResponse<IEnumerable<TagOverrideAdapter>>> GetAllTagOverridesByListService([Header("TrackingId")][Body] GetAllTagOverridesByListRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
[Put("/api/v1/TagOverride/Update")]
|
||||
Task<ApiResponse<TagOverrideAdapter>> UpdateTagOverrideService([Header("TrackingId")][Body] UpdateTagOverrideRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
[Patch("/api/v1/TagOverride/ChangeStatus")]
|
||||
Task<ApiResponse<TagOverrideAdapter>> ChangeTagOverrideStatusService([Header("TrackingId")][Body] ChangeTagOverrideStatusRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/api/v1/TagOverride/Delete")]
|
||||
Task<ApiResponse<TagOverrideAdapter>> DeleteTagOverrideService([Header("TrackingId")][Body] DeleteTagOverrideRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Product
|
||||
@@ -131,6 +163,9 @@ namespace Core.Inventory.External.Clients.Inventory
|
||||
[Delete("/api/v1/Product/RemoveTag")]
|
||||
Task<ApiResponse<ProductAdapter>> RemoveTagFromProductAsync([Header("TrackingId")][Body] RemoveTagFromProductRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/api/v1/Product/Delete")]
|
||||
Task<ApiResponse<ProductAdapter>> DeleteProductService([Header("TrackingId")][Body] DeleteProductRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,5 +12,6 @@ namespace Core.Inventory.External.Clients.Inventory.Requests.Base
|
||||
public string? MaintenanceNotes { get; set; }
|
||||
public DimensionsRequest Dimensions { get; set; } = new();
|
||||
public List<string>? VariantIds { get; set; }
|
||||
public string Icon { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,6 @@ namespace Core.Inventory.External.Clients.Inventory.Requests.Base
|
||||
public string? MaintenanceNotes { get; set; }
|
||||
public DimensionsRequest Dimensions { get; set; } = new();
|
||||
public List<string>? VariantIds { get; set; }
|
||||
public string Icon { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Core.Inventory.External.Clients.Inventory.Requests.Product
|
||||
public string TenantId { get; set; } = null!;
|
||||
public string ProductName { get; set; } = null!;
|
||||
public string Description { get; set; } = null!;
|
||||
public string Status { get; set; } = null!;
|
||||
public string ProductStatus { get; set; } = null!;
|
||||
public List<string> TagIds { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Inventory.External.Clients.Inventory.Requests.Product
|
||||
{
|
||||
public class DeleteProductRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace Core.Inventory.External.Clients.Inventory.Requests.Product
|
||||
public string TenantId { get; set; } = null!;
|
||||
public string ProductName { get; set; } = null!;
|
||||
public string Description { get; set; } = null!;
|
||||
public string Status { get; set; } = null!;
|
||||
public string ProductStatus { get; set; } = null!;
|
||||
public List<string> TagIds { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Inventory.External.Clients.Inventory.Requests.Tag
|
||||
{
|
||||
public class DeleteTagRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Core.Blueprint.Mongo;
|
||||
|
||||
namespace Core.Inventory.External.Clients.Inventory.Requests.TagOverride
|
||||
{
|
||||
public class ChangeTagOverrideStatusRequest
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public StatusEnum Status { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Core.Inventory.External.Clients.Inventory.Requests.TagOverride
|
||||
{
|
||||
public class CreateTagOverrideRequest
|
||||
{
|
||||
public string TenantId { get; set; } = null!;
|
||||
public string BaseTagId { get; set; } = null!;
|
||||
public string OverrideTagId { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Inventory.External.Clients.Inventory.Requests.TagOverride
|
||||
{
|
||||
public class DeleteTagOverrideRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Core.Inventory.External.Clients.Inventory.Requests.TagOverride
|
||||
{
|
||||
public class GetAllTagOverridesByListRequest
|
||||
{
|
||||
public string[] TagOverrides { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Core.Inventory.External.Clients.Inventory.Requests.TagOverride
|
||||
{
|
||||
public class GetAllTagOverridesRequest
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Core.Inventory.External.Clients.Inventory.Requests.TagOverride
|
||||
{
|
||||
public class GetTagOverrideRequest
|
||||
{
|
||||
public string Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Core.Blueprint.Mongo;
|
||||
|
||||
namespace Core.Inventory.External.Clients.Inventory.Requests.TagOverride
|
||||
{
|
||||
public class UpdateTagOverrideRequest
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string TenantId { get; set; } = null!;
|
||||
public string BaseTagId { get; set; } = null!;
|
||||
public string OverrideTagId { get; set; } = null!;
|
||||
public StatusEnum Status { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Inventory.External.Clients.Inventory.Requests.TagType
|
||||
{
|
||||
public class DeleteTagTypeRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,5 +15,6 @@
|
||||
public string ProviderId { get; set; } = string.Empty;
|
||||
|
||||
public Dictionary<string, string> Attributes { get; set; } = [];
|
||||
public string Icon { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,6 @@
|
||||
public string ProviderId { get; set; } = string.Empty;
|
||||
|
||||
public Dictionary<string, string> Attributes { get; set; } = new();
|
||||
public string Icon { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Adapters.Lib" Version="1.0.11" />
|
||||
<PackageReference Include="BuildingBlocks.Library" Version="1.0.0" />
|
||||
<PackageReference Include="Core.Adapters.Lib" Version="1.0.1" />
|
||||
<PackageReference Include="Lib.Architecture.BuildingBlocks" Version="1.0.0" />
|
||||
<PackageReference Include="Refit" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
38
Dockerfile
Normal file
38
Dockerfile
Normal file
@@ -0,0 +1,38 @@
|
||||
# ===== Build stage =====
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /src
|
||||
|
||||
# Usar tu feed (BaGet) + nuget.org
|
||||
COPY nuget.config ./
|
||||
|
||||
# Copiar SOLO los .csproj primero (mejor caché)
|
||||
COPY Core.Inventory.BFF.API/Core.Inventory.BFF.API.csproj Core.Inventory.BFF.API/
|
||||
COPY Core.Inventory.External/Core.Inventory.External.csproj Core.Inventory.External/
|
||||
|
||||
# Restore con tu nuget.config
|
||||
RUN dotnet restore Core.Inventory.BFF.API/Core.Inventory.BFF.API.csproj --configfile ./nuget.config
|
||||
|
||||
# Copiar el resto del código
|
||||
COPY . .
|
||||
|
||||
# Publicar artefactos
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish Core.Inventory.BFF.API/Core.Inventory.BFF.API.csproj \
|
||||
-c $BUILD_CONFIGURATION -o /app/out /p:UseAppHost=false
|
||||
|
||||
# ===== Runtime stage =====
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/out .
|
||||
|
||||
# Config base
|
||||
ENV ASPNETCORE_URLS=http://+:8080 \
|
||||
ASPNETCORE_ENVIRONMENT=Production
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
# (Opcional) Healthcheck si tienes endpoint /health
|
||||
# HEALTHCHECK --interval=30s --timeout=5s --retries=5 \
|
||||
# CMD wget -qO- http://localhost:8080/health || exit 1
|
||||
|
||||
ENTRYPOINT ["dotnet", "Core.Inventory.BFF.API.dll"]
|
||||
9
nuget.config
Normal file
9
nuget.config
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<!-- Tu BaGet primero -->
|
||||
<add key="BaGet" value="https://nuget.dream-views.com/v3/index.json" protocolVersion="3" />
|
||||
<!-- NuGet oficial como fallback (si quieres) -->
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user