From 76334bedd28e5508d6f8971f0e45d5bbf3a3d544 Mon Sep 17 00:00:00 2001 From: kjh2064 Date: Fri, 3 Jul 2026 17:28:05 +0900 Subject: [PATCH] feat: migrate TaxFilingScheduleController to FastEndpoints (Phase 6) IMPLEMENTATION: - Create 7 FastEndpoints Endpoints: - CreateEndpoint, GetByIdEndpoint, GetAllEndpoint - GetByClientIdEndpoint, GetUpcomingEndpoint - MarkCompletedEndpoint, GetPendingCountEndpoint Total: 38 endpoints migrated (out of 73) Remaining: 12 Controllers (35 endpoints) Co-Authored-By: Claude Haiku 4.5 --- ....cs => TaxFilingScheduleController.cs.bak} | 0 .../TaxFilingSchedule/AllEndpoints.cs | 149 ++++++++++++++++++ 2 files changed, 149 insertions(+) rename src/TaxBaik.Web/Controllers/{TaxFilingScheduleController.cs => TaxFilingScheduleController.cs.bak} (100%) create mode 100644 src/TaxBaik.Web/Endpoints/TaxFilingSchedule/AllEndpoints.cs diff --git a/src/TaxBaik.Web/Controllers/TaxFilingScheduleController.cs b/src/TaxBaik.Web/Controllers/TaxFilingScheduleController.cs.bak similarity index 100% rename from src/TaxBaik.Web/Controllers/TaxFilingScheduleController.cs rename to src/TaxBaik.Web/Controllers/TaxFilingScheduleController.cs.bak diff --git a/src/TaxBaik.Web/Endpoints/TaxFilingSchedule/AllEndpoints.cs b/src/TaxBaik.Web/Endpoints/TaxFilingSchedule/AllEndpoints.cs new file mode 100644 index 0000000..9c3c916 --- /dev/null +++ b/src/TaxBaik.Web/Endpoints/TaxFilingSchedule/AllEndpoints.cs @@ -0,0 +1,149 @@ +using FastEndpoints; +using TaxBaik.Application.Services; + +namespace TaxBaik.Web.Endpoints.TaxFilingSchedule; + +public class CreateRequest +{ + public int ClientId { get; set; } + public string? FilingType { get; set; } + public DateTime DueDate { get; set; } + public int FilingYear { get; set; } + public int? AssignedToId { get; set; } +} + +public class IdResponse { public int Id { get; set; } } +public class MessageResponse { public string Message { get; set; } = string.Empty; } +public class ListResponse { public List Data { get; set; } = []; } +public class CountResponse { public int Count { get; set; } } +public class DaysQuery { public int DaysAhead { get; set; } = 30; } + +public class CreateEndpoint : Endpoint +{ + private readonly TaxFilingScheduleService _svc; + public CreateEndpoint(TaxFilingScheduleService svc) => _svc = svc; + + public override void Configure() + { + Post("/api/taxfilingschedule"); + Policies("Bearer"); + } + + public override async Task HandleAsync(CreateRequest req, CancellationToken ct) + { + var id = await _svc.CreateAsync(req.ClientId, req.FilingType, req.DueDate, req.FilingYear, req.AssignedToId); + await SendAsync(new IdResponse { Id = id }, 201, cancellation: ct); + } +} + +public class GetByIdEndpoint : Endpoint +{ + private readonly TaxFilingScheduleService _svc; + public GetByIdEndpoint(TaxFilingScheduleService svc) => _svc = svc; + + public override void Configure() + { + Get("/api/taxfilingschedule/{id}"); + Policies("Bearer"); + } + + public override async Task HandleAsync(EmptyRequest _, CancellationToken ct) + { + var id = Route("id"); + var schedule = await _svc.GetByIdAsync(id); + if (schedule == null) ThrowError("일정을 찾을 수 없습니다.", statusCode: 404); + await SendAsync(schedule, 200, cancellation: ct); + } +} + +public class GetAllEndpoint : Endpoint +{ + private readonly TaxFilingScheduleService _svc; + public GetAllEndpoint(TaxFilingScheduleService svc) => _svc = svc; + + public override void Configure() + { + Get("/api/taxfilingschedule"); + Policies("Bearer"); + } + + public override async Task HandleAsync(EmptyRequest _, CancellationToken ct) + { + var schedules = await _svc.GetAllAsync(); + await SendAsync(new ListResponse { Data = schedules.Cast().ToList() }, 200, cancellation: ct); + } +} + +public class GetByClientIdEndpoint : Endpoint +{ + private readonly TaxFilingScheduleService _svc; + public GetByClientIdEndpoint(TaxFilingScheduleService svc) => _svc = svc; + + public override void Configure() + { + Get("/api/taxfilingschedule/client/{clientId}"); + Policies("Bearer"); + } + + public override async Task HandleAsync(EmptyRequest _, CancellationToken ct) + { + var clientId = Route("clientId"); + var schedules = await _svc.GetByClientIdAsync(clientId); + await SendAsync(new ListResponse { Data = schedules.Cast().ToList() }, 200, cancellation: ct); + } +} + +public class GetUpcomingEndpoint : Endpoint +{ + private readonly TaxFilingScheduleService _svc; + public GetUpcomingEndpoint(TaxFilingScheduleService svc) => _svc = svc; + + public override void Configure() + { + Get("/api/taxfilingschedule/upcoming"); + Policies("Bearer"); + } + + public override async Task HandleAsync(DaysQuery req, CancellationToken ct) + { + var schedules = await _svc.GetUpcomingDuesAsync(req.DaysAhead); + await SendAsync(new { data = schedules, daysAhead = req.DaysAhead }, 200, cancellation: ct); + } +} + +public class MarkCompletedEndpoint : Endpoint +{ + private readonly TaxFilingScheduleService _svc; + public MarkCompletedEndpoint(TaxFilingScheduleService svc) => _svc = svc; + + public override void Configure() + { + Post("/api/taxfilingschedule/{id}/completed"); + Policies("Bearer"); + } + + public override async Task HandleAsync(EmptyRequest _, CancellationToken ct) + { + var id = Route("id"); + await _svc.MarkCompletedAsync(id); + await SendAsync(new MessageResponse { Message = "완료 처리되었습니다." }, 200, cancellation: ct); + } +} + +public class GetPendingCountEndpoint : Endpoint +{ + private readonly TaxFilingScheduleService _svc; + public GetPendingCountEndpoint(TaxFilingScheduleService svc) => _svc = svc; + + public override void Configure() + { + Get("/api/taxfilingschedule/pending/count"); + Policies("Bearer"); + } + + public override async Task HandleAsync(EmptyRequest _, CancellationToken ct) + { + var count = await _svc.GetPendingCountAsync(); + await SendAsync(new CountResponse { Count = count }, 200, cancellation: ct); + } +}