fix: 健康仪表盘单位下移 + 档案按钮浅紫 + AI问诊胶囊改名 + 删除账号功能

This commit is contained in:
MingNian
2026-06-17 17:35:47 +08:00
parent 0f2a9c1c1a
commit fbaed0cf1d
11 changed files with 1289 additions and 1500 deletions

View File

@@ -73,8 +73,33 @@ public static class UserEndpoints
group.MapDelete("/account", async (HttpContext http, AppDbContext db, CancellationToken ct) =>
{
var userId = GetUserId(http);
var user = await db.Users.FindAsync([userId], ct);
if (user != null) { db.Users.Remove(user); await db.SaveChangesAsync(ct); }
// 医生清除Doctor关联
var profile = await db.DoctorProfiles.FirstOrDefaultAsync(p => p.UserId == userId, ct);
if (profile?.DoctorId != null)
{
await db.Users.Where(u => u.DoctorId == profile!.DoctorId).ExecuteUpdateAsync(u => u.SetProperty(x => x.DoctorId, (Guid?)null), ct);
await db.Doctors.Where(d => d.Id == profile.DoctorId).ExecuteDeleteAsync(ct);
}
// 删除所有关联数据
await db.HealthRecords.Where(r => r.UserId == userId).ExecuteDeleteAsync(ct);
await db.MedicationLogs.Where(l => l.UserId == userId).ExecuteDeleteAsync(ct);
await db.Medications.Where(m => m.UserId == userId).ExecuteDeleteAsync(ct);
await db.DietFoodItems.Where(i => i.DietRecord!.UserId == userId).ExecuteDeleteAsync(ct);
await db.DietRecords.Where(d => d.UserId == userId).ExecuteDeleteAsync(ct);
await db.ExercisePlanItems.Where(i => i.Plan!.UserId == userId).ExecuteDeleteAsync(ct);
await db.ExercisePlans.Where(p => p.UserId == userId).ExecuteDeleteAsync(ct);
await db.Reports.Where(r => r.UserId == userId).ExecuteDeleteAsync(ct);
await db.ConversationMessages.Where(m => m.Conversation!.UserId == userId).ExecuteDeleteAsync(ct);
await db.Conversations.Where(c => c.UserId == userId).ExecuteDeleteAsync(ct);
await db.ConsultationMessages.Where(m => m.Consultation!.UserId == userId).ExecuteDeleteAsync(ct);
await db.Consultations.Where(c => c.UserId == userId).ExecuteDeleteAsync(ct);
await db.FollowUps.Where(f => f.UserId == userId).ExecuteDeleteAsync(ct);
await db.RefreshTokens.Where(t => t.UserId == userId).ExecuteDeleteAsync(ct);
await db.DeviceTokens.Where(t => t.UserId == userId).ExecuteDeleteAsync(ct);
await db.NotificationPreferences.Where(p => p.UserId == userId).ExecuteDeleteAsync(ct);
await db.HealthArchives.Where(a => a.UserId == userId).ExecuteDeleteAsync(ct);
await db.DoctorProfiles.Where(p => p.UserId == userId).ExecuteDeleteAsync(ct);
await db.Users.Where(u => u.Id == userId).ExecuteDeleteAsync(ct);
return Results.Ok(new { code = 0, data = new { success = true }, message = (string?)null });
});
}