- 核心业务拆分为 Endpoint → Application Service → Repository 三层 - AI写入操作必须用户确认后才写库(确认卡片机制) - 报告/饮食/用药分析改为持久化任务队列(原子领取/重试/重启恢复) - 运动计划修复: 连续真实日期替代周模板 - 用药提醒去重 + 通知Outbox预留 - 认证收拢到AuthService, 管理员收拢到AdminService - AI会话加用户归属校验防串号 - 提示词调整为患者视角 - 开发假数据已关闭 - 21/21测试通过, 0警告0错误
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using Health.Domain.Entities;
|
|
using Health.Domain.Enums;
|
|
|
|
namespace Health.Application.Diets;
|
|
|
|
public sealed record DietFoodItemInput(
|
|
string Name,
|
|
string? Portion,
|
|
int? Calories,
|
|
int SortOrder);
|
|
|
|
public sealed record DietRecordCreateRequest(
|
|
MealType MealType,
|
|
int? TotalCalories,
|
|
int? HealthScore,
|
|
DateOnly RecordedAt,
|
|
IReadOnlyList<DietFoodItemInput> FoodItems);
|
|
|
|
public sealed record DietRecordPatchRequest(
|
|
int? TotalCalories,
|
|
int? HealthScore);
|
|
|
|
public sealed record DietFoodItemDto(
|
|
string Name,
|
|
string? Portion,
|
|
int? Calories);
|
|
|
|
public sealed record DietRecordDto(
|
|
Guid Id,
|
|
string MealType,
|
|
int? TotalCalories,
|
|
int? HealthScore,
|
|
DateOnly RecordedAt,
|
|
IReadOnlyList<DietFoodItemDto> FoodItems);
|
|
|
|
public interface IDietService
|
|
{
|
|
Task<IReadOnlyList<DietRecordDto>> ListAsync(Guid userId, string? date, string? mealType, CancellationToken ct);
|
|
Task<Guid> CreateAsync(Guid userId, DietRecordCreateRequest request, CancellationToken ct);
|
|
Task<bool> DeleteAsync(Guid userId, Guid recordId, CancellationToken ct);
|
|
Task<bool> UpdateAsync(Guid userId, Guid recordId, DietRecordPatchRequest request, CancellationToken ct);
|
|
}
|
|
|
|
public interface IDietRepository
|
|
{
|
|
Task<IReadOnlyList<DietRecord>> ListAsync(Guid userId, DateOnly? recordedAt, MealType? mealType, CancellationToken ct);
|
|
Task<DietRecord?> GetOwnedAsync(Guid userId, Guid recordId, CancellationToken ct);
|
|
Task AddAsync(DietRecord record, CancellationToken ct);
|
|
void Delete(DietRecord record);
|
|
Task SaveChangesAsync(CancellationToken ct);
|
|
}
|