Implement API security baseline (sys_user, JWT, audit fields, transactions, unique constraints) and Web real login with 401 handling. Document setup and development workflows in root, WmsLite.Api, and WmsLite.Web README files. Co-authored-by: Cursor <cursoragent@cursor.com>
60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using WmsLite.Api.Common;
|
|
using WmsLite.Api.Dtos.Inventory;
|
|
using WmsLite.Api.Infrastructure.Auth;
|
|
using WmsLite.Api.Services.Interfaces;
|
|
|
|
namespace WmsLite.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class InventoryController : WmsLiteControllerBase
|
|
{
|
|
private readonly IInventoryService _inventoryService;
|
|
|
|
public InventoryController(IInventoryService inventoryService, ICurrentUserContext currentUser)
|
|
: base(currentUser)
|
|
{
|
|
_inventoryService = inventoryService;
|
|
}
|
|
|
|
[HttpPost("move")]
|
|
public async Task<ActionResult<BusinessResult>> Move([FromBody] InventoryMoveRequest request)
|
|
{
|
|
var result = await _inventoryService.MoveAsync(request);
|
|
return result is null
|
|
? NotFound(BusinessResult.NotFound("Resource not found."))
|
|
: Ok(BusinessResult.Ok(result));
|
|
}
|
|
|
|
[HttpPost("paged-list")]
|
|
public async Task<ActionResult<BusinessResult>> GetPagedList([FromBody] InventoryPagedQuery request)
|
|
{
|
|
var result = await _inventoryService.GetPagedListAsync(request);
|
|
return Ok(BusinessResult.Ok(result));
|
|
}
|
|
|
|
[HttpPost("create")]
|
|
public async Task<ActionResult<BusinessResult>> Create([FromBody] InventorySaveRequest request)
|
|
{
|
|
var result = await _inventoryService.CreateAsync(request);
|
|
return Ok(BusinessResult.Ok(result));
|
|
}
|
|
|
|
[HttpPut("update")]
|
|
public async Task<ActionResult<BusinessResult>> Update([FromBody] InventoryUpdateRequest request)
|
|
{
|
|
var result = await _inventoryService.UpdateAsync(request);
|
|
return result is null
|
|
? NotFound(BusinessResult.NotFound("Resource not found."))
|
|
: Ok(BusinessResult.Ok(result));
|
|
}
|
|
|
|
[HttpDelete("{id:long}")]
|
|
public async Task<ActionResult<BusinessResult>> Delete(long id)
|
|
{
|
|
var affectedRows = await _inventoryService.DeleteAsync(id, TenantId, OwnerCode);
|
|
return Ok(BusinessResult.Ok(new { AffectedRows = affectedRows }));
|
|
}
|
|
}
|