feat: add ci

This commit is contained in:
2026-09-13 18:02:09 +07:00
parent af34bc11f1
commit ed5146c73b
21 changed files with 186 additions and 2477 deletions
@@ -1,16 +1,36 @@
using Microsoft.EntityFrameworkCore;
using mws.backend.dotnet.application.Common;
using mws.backend.dotnet.application.Common.Repositories;
using mws.backend.dotnet.application.MasterData;
using mws.backend.dotnet.domain.MasterData;
namespace mws.backend.dotnet.infrastructure.Persistence.Repositories;
public class MasterDataRepository(AppDbContext db) : RepositoryBase<MasterDataEntry>(db), IMasterDataRepository
{
public Task<PagedResult<MasterDataEntry>> GetAllAsync(string? group, int page, int pageSize, CancellationToken ct = default) =>
Set.Where(m => group == null || m.Group == group)
.OrderBy(m => m.Group).ThenBy(m => m.SortOrder).ThenBy(m => m.Label)
public Task<PagedResult<MasterDataEntry>> GetAllAsync(MasterDataFilter filter, int page, int pageSize, CancellationToken ct = default)
{
var query = Set.AsQueryable();
if (!string.IsNullOrWhiteSpace(filter.Group))
{
query = query.Where(m => m.Group == filter.Group);
}
if (!string.IsNullOrWhiteSpace(filter.Term))
{
var lower = filter.Term.Trim().ToLower();
query = query.Where(m => m.Label.ToLower().Contains(lower) || m.Value.ToLower().Contains(lower));
}
if (filter.IsActive is { } active)
{
query = query.Where(m => m.IsActive == active);
}
return query.OrderBy(m => m.Group).ThenBy(m => m.SortOrder).ThenBy(m => m.Label)
.ToPagedResultAsync(page, pageSize, ct);
}
public Task<List<MasterDataEntry>> GetActiveByGroupAsync(string group, CancellationToken ct = default) =>
Set.Where(m => m.Group == group && m.IsActive)