From f2ab78dea28990c4b642c8caed2e21221f153789 Mon Sep 17 00:00:00 2001 From: kjh2064 Date: Mon, 29 Jun 2026 23:13:46 +0900 Subject: [PATCH] =?UTF-8?q?=EC=88=98=EC=9D=B5=20=EC=B6=94=EC=A0=81=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20API=20=EB=B3=B5=EC=9B=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/RevenueTrackingService.cs | 3 +++ .../Interfaces/IRevenueTrackingRepository.cs | 1 + .../Repositories/RevenueTrackingRepository.cs | 9 +++++++++ TaxBaik.Web/Controllers/RevenueTrackingController.cs | 12 ++++++++---- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/TaxBaik.Application/Services/RevenueTrackingService.cs b/TaxBaik.Application/Services/RevenueTrackingService.cs index be9c66c..528236d 100644 --- a/TaxBaik.Application/Services/RevenueTrackingService.cs +++ b/TaxBaik.Application/Services/RevenueTrackingService.cs @@ -34,6 +34,9 @@ public class RevenueTrackingService(IRevenueTrackingRepository repository) public async Task> GetByClientIdAsync(int clientId, CancellationToken ct = default) => await repository.GetByClientIdAsync(clientId, ct); + public async Task GetByIdAsync(int id, CancellationToken ct = default) => + await repository.GetByIdAsync(id, ct); + public async Task> GetAllAsync(CancellationToken ct = default) => await repository.GetAllAsync(ct); diff --git a/TaxBaik.Domain/Interfaces/IRevenueTrackingRepository.cs b/TaxBaik.Domain/Interfaces/IRevenueTrackingRepository.cs index 498402b..6a1563f 100644 --- a/TaxBaik.Domain/Interfaces/IRevenueTrackingRepository.cs +++ b/TaxBaik.Domain/Interfaces/IRevenueTrackingRepository.cs @@ -5,6 +5,7 @@ using TaxBaik.Domain.Entities; public interface IRevenueTrackingRepository { Task CreateAsync(RevenueTracking revenue, CancellationToken cancellationToken = default); + Task GetByIdAsync(int id, CancellationToken cancellationToken = default); Task> GetAllAsync(CancellationToken cancellationToken = default); Task> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default); Task> GetPendingPaymentsAsync(CancellationToken cancellationToken = default); diff --git a/TaxBaik.Infrastructure/Repositories/RevenueTrackingRepository.cs b/TaxBaik.Infrastructure/Repositories/RevenueTrackingRepository.cs index a6fe61a..806d9c7 100644 --- a/TaxBaik.Infrastructure/Repositories/RevenueTrackingRepository.cs +++ b/TaxBaik.Infrastructure/Repositories/RevenueTrackingRepository.cs @@ -24,6 +24,15 @@ public class RevenueTrackingRepository(IDbConnectionFactory connectionFactory) : FROM revenue_tracking ORDER BY invoice_date DESC"); } + public async Task GetByIdAsync(int id, CancellationToken cancellationToken = default) + { + using var conn = Conn(); + return await conn.QueryFirstOrDefaultAsync( + @"SELECT id, client_id, invoice_number, invoice_date, service_type, amount, payment_status, payment_date, due_date, notes, created_at, updated_at + FROM revenue_tracking WHERE id = @Id", + new { Id = id }); + } + public async Task> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default) { using var conn = Conn(); diff --git a/TaxBaik.Web/Controllers/RevenueTrackingController.cs b/TaxBaik.Web/Controllers/RevenueTrackingController.cs index d850125..da54eba 100644 --- a/TaxBaik.Web/Controllers/RevenueTrackingController.cs +++ b/TaxBaik.Web/Controllers/RevenueTrackingController.cs @@ -41,11 +41,15 @@ public class RevenueTrackingController(RevenueTrackingService service) : Control [HttpGet("{id:int}")] public async Task GetById(int id) { - return StatusCode(StatusCodes.Status501NotImplemented, new + try { - error = "미구현", - message = "RevenueTrackingService.GetByIdAsync 구현이 필요합니다." - }); + var revenue = await service.GetByIdAsync(id); + return revenue is null ? NotFound(new { error = "조회 실패", message = "해당 청구를 찾을 수 없습니다." }) : Ok(revenue); + } + catch (Exception ex) + { + return StatusCode(500, new { error = "조회 실패", message = ex.Message }); + } } [HttpGet("client/{clientId:int}")]