diff --git a/TaxBaik.Application/Services/RevenueTrackingService.cs b/TaxBaik.Application/Services/RevenueTrackingService.cs index d9a3b2e..be9c66c 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> GetAllAsync(CancellationToken ct = default) => + await repository.GetAllAsync(ct); + public async Task> GetPendingPaymentsAsync(CancellationToken ct = default) => await repository.GetPendingPaymentsAsync(ct); diff --git a/TaxBaik.Domain/Interfaces/IRevenueTrackingRepository.cs b/TaxBaik.Domain/Interfaces/IRevenueTrackingRepository.cs index f1a04aa..498402b 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> GetAllAsync(CancellationToken cancellationToken = default); Task> GetByClientIdAsync(int clientId, CancellationToken cancellationToken = default); Task> GetPendingPaymentsAsync(CancellationToken cancellationToken = default); Task> GetByDateRangeAsync(DateTime startDate, DateTime endDate, CancellationToken cancellationToken = default); diff --git a/TaxBaik.Infrastructure/Repositories/RevenueTrackingRepository.cs b/TaxBaik.Infrastructure/Repositories/RevenueTrackingRepository.cs index 8a527a9..a6fe61a 100644 --- a/TaxBaik.Infrastructure/Repositories/RevenueTrackingRepository.cs +++ b/TaxBaik.Infrastructure/Repositories/RevenueTrackingRepository.cs @@ -16,6 +16,14 @@ public class RevenueTrackingRepository(IDbConnectionFactory connectionFactory) : revenue); } + public async Task> GetAllAsync(CancellationToken cancellationToken = default) + { + using var conn = Conn(); + return await conn.QueryAsync( + @"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 ORDER BY invoice_date DESC"); + } + 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 c4e4f1b..0534ee1 100644 --- a/TaxBaik.Web/Controllers/RevenueTrackingController.cs +++ b/TaxBaik.Web/Controllers/RevenueTrackingController.cs @@ -24,6 +24,20 @@ public class RevenueTrackingController(RevenueTrackingService service) : Control } } + [HttpGet] + public async Task GetAll() + { + try + { + var revenues = await service.GetAllAsync(); + return Ok(revenues); + } + catch (Exception ex) + { + return StatusCode(500, new { error = "조회 실패", message = ex.Message }); + } + } + [HttpGet("{id:int}")] public async Task GetById(int id) {