Add WmsLite monorepo with JWT auth, tenant context, and project READMEs.
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>
This commit is contained in:
commit
fa1b286463
241 files changed
+31188
No files matched your search
@@ -0,0 +1,58 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using WmsLite.Api.Common;
|
||||
|
||||
namespace WmsLite.Api.Controllers;
|
||||
|
||||
[AllowAnonymous]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class HealthController : ControllerBase
|
||||
{
|
||||
private readonly ISqlSugarClient _sqlSugarClient;
|
||||
|
||||
public HealthController(ISqlSugarClient sqlSugarClient)
|
||||
{
|
||||
_sqlSugarClient = sqlSugarClient;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult<BusinessResult> Get()
|
||||
{
|
||||
return Ok(BusinessResult.Ok(new
|
||||
{
|
||||
Name = "WmsLite API",
|
||||
Status = "OK",
|
||||
Time = DateTimeOffset.UtcNow
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>探活 PostgreSQL(连接池取连执行 SELECT 1)。</summary>
|
||||
[HttpGet("db")]
|
||||
public async Task<ActionResult<BusinessResult>> Db()
|
||||
{
|
||||
try
|
||||
{
|
||||
var scalar = await _sqlSugarClient.Ado.SqlQuerySingleAsync<int>("SELECT 1");
|
||||
if (scalar != 1)
|
||||
{
|
||||
return StatusCode(
|
||||
StatusCodes.Status503ServiceUnavailable,
|
||||
BusinessResult.Fail("Database check returned unexpected result.", "503"));
|
||||
}
|
||||
|
||||
return Ok(BusinessResult.Ok(new
|
||||
{
|
||||
Database = "OK",
|
||||
Time = DateTimeOffset.UtcNow
|
||||
}));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(
|
||||
StatusCodes.Status503ServiceUnavailable,
|
||||
BusinessResult.Fail($"Database unavailable: {ex.Message}", "503"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user