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,37 @@
using MiaoJiZhang.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
namespace MiaoJiZhang.Api.Services;
public class AccountDataEraser(AppDbContext db)
{
public async Task EraseAsync(long userId, CancellationToken ct = default)
{
await using var transaction =
await db.Database.BeginTransactionAsync(ct);
await db.ChatMessages
.Where(message => message.UserId == userId)
.ExecuteDeleteAsync(ct);
await db.Transactions
.IgnoreQueryFilters()
.Where(item => item.UserId == userId)
.ExecuteDeleteAsync(ct);
await db.Budgets
.Where(item => item.UserId == userId)
.ExecuteDeleteAsync(ct);
await db.Categories
.Where(item => item.UserId == userId)
.ExecuteDeleteAsync(ct);
await db.AiCompanionSettings
.Where(item => item.UserId == userId)
.ExecuteDeleteAsync(ct);
await db.Ledgers
.Where(item => item.OwnerId == userId)
.ExecuteDeleteAsync(ct);
await db.Users
.Where(item => item.Id == userId)
.ExecuteDeleteAsync(ct);
await transaction.CommitAsync(ct);
}
}