- 核心业务拆分为 Endpoint → Application Service → Repository 三层 - AI写入操作必须用户确认后才写库(确认卡片机制) - 报告/饮食/用药分析改为持久化任务队列(原子领取/重试/重启恢复) - 运动计划修复: 连续真实日期替代周模板 - 用药提醒去重 + 通知Outbox预留 - 认证收拢到AuthService, 管理员收拢到AdminService - AI会话加用户归属校验防串号 - 提示词调整为患者视角 - 开发假数据已关闭 - 21/21测试通过, 0警告0错误
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
namespace Health.Application.Users;
|
|
|
|
public sealed class UserService(IUserRepository users) : IUserService
|
|
{
|
|
private readonly IUserRepository _users = users;
|
|
|
|
public async Task<UserProfileDto?> GetProfileAsync(Guid userId, CancellationToken ct)
|
|
{
|
|
var user = await _users.GetAsync(userId, ct);
|
|
return user == null ? null : new UserProfileDto(
|
|
user.Id,
|
|
user.Phone,
|
|
user.Role,
|
|
user.Name,
|
|
user.Gender,
|
|
user.BirthDate?.ToString("yyyy-MM-dd"),
|
|
user.AvatarUrl);
|
|
}
|
|
|
|
public async Task<bool> UpdateProfileAsync(Guid userId, UserProfileUpdateRequest request, CancellationToken ct)
|
|
{
|
|
var user = await _users.GetAsync(userId, ct);
|
|
if (user == null) return false;
|
|
|
|
if (request.Name != null) user.Name = request.Name;
|
|
if (request.Gender != null) user.Gender = request.Gender;
|
|
if (request.BirthDate.HasValue) user.BirthDate = request.BirthDate.Value;
|
|
user.UpdatedAt = DateTime.UtcNow;
|
|
await _users.SaveChangesAsync(ct);
|
|
return true;
|
|
}
|
|
|
|
public Task DeleteAccountAsync(Guid userId, CancellationToken ct) =>
|
|
_users.DeleteAccountDataAsync(userId, ct);
|
|
}
|