Initial project import

This commit is contained in:
2026-07-24 23:11:20 +08:00
commit 6396eabb87
372 changed files with 49682 additions and 0 deletions
@@ -0,0 +1,26 @@
using MiaoJiZhang.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
namespace MiaoJiZhang.Api.Services;
public class LedgerResolver(AppDbContext db)
{
public async Task<long?> ResolveAsync(
long userId,
long? requestedLedgerId,
CancellationToken ct = default)
{
if (requestedLedgerId.HasValue)
{
return await db.Ledgers
.Where(l => l.Id == requestedLedgerId.Value && l.OwnerId == userId)
.Select(l => (long?)l.Id)
.FirstOrDefaultAsync(ct);
}
return await db.Ledgers
.Where(l => l.OwnerId == userId && l.IsDefault)
.Select(l => (long?)l.Id)
.FirstOrDefaultAsync(ct);
}
}