V13-FE-011: finalize search list layout slice
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
using Dapper;
|
||||
using FastEndpoints;
|
||||
using Npgsql;
|
||||
|
||||
namespace Modules.OMS.Lookups.Items;
|
||||
|
||||
public sealed class ResolveByCodeEndpoint(NpgsqlDataSource dataSource) : EndpointWithoutRequest
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/lookups/items/by-code/{code}");
|
||||
Permissions("erp.item.read");
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
var code = Route<string>("code");
|
||||
await using var connection = await dataSource.OpenConnectionAsync(ct);
|
||||
var item = await connection.QuerySingleOrDefaultAsync(new CommandDefinition(@"
|
||||
select id, code, name as DisplayName, case when is_active then '사용' else '중지' end as Status
|
||||
from catalog.items where code=@Code and is_active=true;", new { Code = code }, cancellationToken: ct));
|
||||
if (item is null) { await Send.NotFoundAsync(ct); return; }
|
||||
await Send.OkAsync(item, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user