fix: doctor can see patient-created follow-ups, camelCase JSON support

- FollowUpService: doctor query includes unassigned (DoctorId=null) follow-ups
- FollowUpController: doctor creates follow-up with correct patientId and sets DoctorId
- FollowUpCreateRequest/UpdateRequest: changed from positional record to class for System.Text.Json compat
- Program.cs: added PropertyNameCaseInsensitive for camelCase JSON deserialization
This commit is contained in:
MingNian
2026-05-22 15:38:08 +08:00
parent 9d384dc6fb
commit 94da24572e
3 changed files with 33 additions and 7 deletions

View File

@@ -45,8 +45,17 @@ public class FollowUpController(FollowUpService followUpService) : ControllerBas
[HttpPost]
public async Task<IActionResult> AddFollowUp([FromBody] FollowUpCreateRequest request)
{
var followUp = await followUpService.AddAsync(UserId, request.Title, request.Description,
request.ScheduledAt, request.ReminderEnabled);
var patientId = UserId;
Guid? doctorId = null;
if (Role == "doctor" && request.PatientId.HasValue)
{
patientId = request.PatientId.Value;
doctorId = UserId;
}
var followUp = await followUpService.AddAsync(patientId, request.Title, request.Description,
request.ScheduledAt, request.ReminderEnabled, doctorId);
return Ok(new { followUp.Id, followUp.Title, followUp.Status });
}
@@ -61,7 +70,20 @@ public class FollowUpController(FollowUpService followUpService) : ControllerBas
}
}
public record FollowUpCreateRequest(string Title, string? Description, DateTime ScheduledAt, bool ReminderEnabled = true);
public class FollowUpCreateRequest
{
public string Title { get; set; } = string.Empty;
public string? Description { get; set; }
public DateTime ScheduledAt { get; set; }
public bool ReminderEnabled { get; set; } = true;
public Guid? PatientId { get; set; }
}
public record FollowUpUpdateRequest(
string? Title, string? Description, DateTime? ScheduledAt, string? Status, string? Notes);
public class FollowUpUpdateRequest
{
public string? Title { get; set; }
public string? Description { get; set; }
public DateTime? ScheduledAt { get; set; }
public string? Status { get; set; }
public string? Notes { get; set; }
}

View File

@@ -74,7 +74,11 @@ builder.Services.AddCors(options =>
});
});
builder.Services.AddControllers();
builder.Services.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
});
var app = builder.Build();