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>
67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using WmsLite.Api.Common;
|
|
using WmsLite.Api.Dtos.Location;
|
|
using WmsLite.Api.Infrastructure.Auth;
|
|
using WmsLite.Api.Services.Interfaces;
|
|
|
|
namespace WmsLite.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class LocationController : WmsLiteControllerBase
|
|
{
|
|
private readonly ILocationService _locationService;
|
|
|
|
public LocationController(ILocationService locationService, ICurrentUserContext currentUser)
|
|
: base(currentUser)
|
|
{
|
|
_locationService = locationService;
|
|
}
|
|
|
|
[HttpPost("paged-list")]
|
|
public async Task<ActionResult<BusinessResult>> GetPagedList([FromBody] LocationPagedQuery request)
|
|
{
|
|
var result = await _locationService.GetPagedListAsync(request);
|
|
return Ok(BusinessResult.Ok(result));
|
|
}
|
|
|
|
[HttpGet("{id:long}")]
|
|
public async Task<ActionResult<BusinessResult>> GetById(long id)
|
|
{
|
|
var result = await _locationService.GetByIdAsync(id, TenantId, OwnerCode);
|
|
return result is null
|
|
? NotFound(BusinessResult.NotFound("Resource not found."))
|
|
: Ok(BusinessResult.Ok(result));
|
|
}
|
|
|
|
[HttpPost("batch-create")]
|
|
public async Task<ActionResult<BusinessResult>> BatchCreate([FromBody] LocationBatchCreateRequest request)
|
|
{
|
|
var result = await _locationService.BatchCreateAsync(request);
|
|
return Ok(BusinessResult.Ok(result));
|
|
}
|
|
|
|
[HttpPost("create")]
|
|
public async Task<ActionResult<BusinessResult>> Create([FromBody] LocationSaveRequest request)
|
|
{
|
|
var result = await _locationService.CreateAsync(request);
|
|
return Ok(BusinessResult.Ok(result));
|
|
}
|
|
|
|
[HttpPut("update")]
|
|
public async Task<ActionResult<BusinessResult>> Update([FromBody] LocationUpdateRequest request)
|
|
{
|
|
var result = await _locationService.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 _locationService.DeleteAsync(id, TenantId, OwnerCode);
|
|
return Ok(BusinessResult.Ok(new { AffectedRows = affectedRows }));
|
|
}
|
|
}
|