V13-FE-011: finalize search list layout slice

This commit is contained in:
2026-08-09 02:57:26 +09:00
parent 9efd202e76
commit 6422cb2b13
984 changed files with 120811 additions and 1498 deletions
@@ -0,0 +1,32 @@
using Dapper;
using FastEndpoints;
using Npgsql;
namespace Modules.OMS.Lookups.Customers;
public sealed class Endpoint(NpgsqlDataSource dataSource) : EndpointWithoutRequest
{
public override void Configure()
{
Get("/api/lookups/customers");
Permissions("oms.order.read");
}
public override async Task HandleAsync(CancellationToken ct)
{
var query = Query<string>("query", false) ?? string.Empty;
var page = Math.Max(1, Query<int>("page", false));
var pageSize = Math.Clamp(Query<int>("pageSize", false), 1, 100);
await using var connection = await dataSource.OpenConnectionAsync(ct);
var items = (await connection.QueryAsync(new CommandDefinition(@"
select id, code, name as DisplayName, case when is_active then '사용' else '중지' end as Status
from oms.customers
where is_active = true and (@Query = '' or code ilike '%' || @Query || '%' or name ilike '%' || @Query || '%')
order by code
offset @Offset limit @PageSize;", new { Query = query, Offset = (page - 1) * pageSize, PageSize = pageSize }, cancellationToken: ct))).ToArray();
var count = await connection.ExecuteScalarAsync<int>(new CommandDefinition(@"
select count(*) from oms.customers
where is_active = true and (@Query = '' or code ilike '%' || @Query || '%' or name ilike '%' || @Query || '%');", new { Query = query }, cancellationToken: ct));
await Send.OkAsync(new { items, totalCount = count }, ct);
}
}
@@ -0,0 +1,25 @@
using Dapper;
using FastEndpoints;
using Npgsql;
namespace Modules.OMS.Lookups.Customers;
public sealed class ResolveByCodeEndpoint(NpgsqlDataSource dataSource) : EndpointWithoutRequest
{
public override void Configure()
{
Get("/api/lookups/customers/by-code/{code}");
Permissions("oms.order.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 oms.customers 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);
}
}
@@ -0,0 +1,25 @@
using Dapper;
using FastEndpoints;
using Npgsql;
namespace Modules.OMS.Lookups.Customers;
public sealed class ResolveEndpoint(NpgsqlDataSource dataSource) : EndpointWithoutRequest
{
public override void Configure()
{
Get("/api/lookups/customers/{id}");
Permissions("oms.order.read");
}
public override async Task HandleAsync(CancellationToken ct)
{
var id = Route<Guid>("id");
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 oms.customers where id=@Id;", new { Id = id }, cancellationToken: ct));
if (item is null) { await Send.NotFoundAsync(ct); return; }
await Send.OkAsync(item, ct);
}
}
@@ -0,0 +1,33 @@
using Dapper;
using FastEndpoints;
using Npgsql;
namespace Modules.OMS.Lookups.Items;
public sealed class Endpoint(NpgsqlDataSource dataSource) : EndpointWithoutRequest
{
public override void Configure()
{
Get("/api/lookups/items");
Permissions("erp.item.read");
}
public override async Task HandleAsync(CancellationToken ct)
{
var query = Query<string>("query", false) ?? string.Empty;
var page = Math.Max(1, Query<int>("page", false));
var requestedPageSize = Query<int>("pageSize", false);
var pageSize = Math.Clamp(requestedPageSize == 0 ? 30 : requestedPageSize, 1, 100);
await using var connection = await dataSource.OpenConnectionAsync(ct);
var items = (await connection.QueryAsync(new CommandDefinition(@"
select id, code, name as DisplayName, case when is_active then '사용' else '중지' end as Status
from catalog.items
where is_active = true and (@Query = '' or code ilike '%' || @Query || '%' or name ilike '%' || @Query || '%')
order by code
offset @Offset limit @PageSize;", new { Query = query, Offset = (page - 1) * pageSize, PageSize = pageSize }, cancellationToken: ct))).ToArray();
var count = await connection.ExecuteScalarAsync<int>(new CommandDefinition(@"
select count(*) from catalog.items
where is_active = true and (@Query = '' or code ilike '%' || @Query || '%' or name ilike '%' || @Query || '%');", new { Query = query }, cancellationToken: ct));
await Send.OkAsync(new { items, totalCount = count }, ct);
}
}
@@ -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);
}
}
@@ -0,0 +1,25 @@
using Dapper;
using FastEndpoints;
using Npgsql;
namespace Modules.OMS.Lookups.Items;
public sealed class ResolveEndpoint(NpgsqlDataSource dataSource) : EndpointWithoutRequest
{
public override void Configure()
{
Get("/api/lookups/items/{id}");
Permissions("erp.item.read");
}
public override async Task HandleAsync(CancellationToken ct)
{
var id = Route<Guid>("id");
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 id=@Id;", new { Id = id }, cancellationToken: ct));
if (item is null) { await Send.NotFoundAsync(ct); return; }
await Send.OkAsync(item, ct);
}
}
@@ -0,0 +1,33 @@
using Dapper;
using FastEndpoints;
using Npgsql;
namespace Modules.OMS.Lookups.Warehouses;
public sealed class Endpoint(NpgsqlDataSource dataSource) : EndpointWithoutRequest
{
public override void Configure()
{
Get("/api/lookups/warehouses");
Permissions("oms.order.read");
}
public override async Task HandleAsync(CancellationToken ct)
{
var query = Query<string>("query", false) ?? string.Empty;
var page = Math.Max(1, Query<int>("page", false));
var requestedPageSize = Query<int>("pageSize", false);
var pageSize = Math.Clamp(requestedPageSize == 0 ? 30 : requestedPageSize, 1, 100);
await using var connection = await dataSource.OpenConnectionAsync(ct);
var items = (await connection.QueryAsync(new CommandDefinition(@"
select id, code, name as DisplayName, case when is_active then '사용' else '중지' end as Status
from inventory.warehouses
where is_active = true and (@Query = '' or code ilike '%' || @Query || '%' or name ilike '%' || @Query || '%')
order by code
offset @Offset limit @PageSize;", new { Query = query, Offset = (page - 1) * pageSize, PageSize = pageSize }, cancellationToken: ct))).ToArray();
var count = await connection.ExecuteScalarAsync<int>(new CommandDefinition(@"
select count(*) from inventory.warehouses
where is_active = true and (@Query = '' or code ilike '%' || @Query || '%' or name ilike '%' || @Query || '%');", new { Query = query }, cancellationToken: ct));
await Send.OkAsync(new { items, totalCount = count }, ct);
}
}
@@ -0,0 +1,25 @@
using Dapper;
using FastEndpoints;
using Npgsql;
namespace Modules.OMS.Lookups.Warehouses;
public sealed class ResolveByCodeEndpoint(NpgsqlDataSource dataSource) : EndpointWithoutRequest
{
public override void Configure()
{
Get("/api/lookups/warehouses/by-code/{code}");
Permissions("oms.order.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 inventory.warehouses 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);
}
}
@@ -0,0 +1,25 @@
using Dapper;
using FastEndpoints;
using Npgsql;
namespace Modules.OMS.Lookups.Warehouses;
public sealed class ResolveEndpoint(NpgsqlDataSource dataSource) : EndpointWithoutRequest
{
public override void Configure()
{
Get("/api/lookups/warehouses/{id}");
Permissions("oms.order.read");
}
public override async Task HandleAsync(CancellationToken ct)
{
var id = Route<Guid>("id");
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 inventory.warehouses where id=@Id;", new { Id = id }, cancellationToken: ct));
if (item is null) { await Send.NotFoundAsync(ct); return; }
await Send.OkAsync(item, ct);
}
}