From da2001c79b611661d14c28cd704ee4e09dd09f99 Mon Sep 17 00:00:00 2001 From: SEAN Date: Mon, 9 Feb 2026 13:46:06 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Domain=20Interface=20=EC=A0=95=EC=9D=98?= =?UTF-8?q?=20=E2=80=94=20Repository,=20UnitOfWork=20(#12)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit IRepository Generic CRUD, IUnitOfWork 트랜잭션, 도메인별 특화 Repository 인터페이스 7종 정의 (Service, Admin, Device, Message, PushLog, File, Stat) --- SPMS.Domain/Interfaces/IAdminRepository.cs | 10 ++++++++++ SPMS.Domain/Interfaces/IDeviceRepository.cs | 11 ++++++++++ SPMS.Domain/Interfaces/IFileRepository.cs | 9 +++++++++ SPMS.Domain/Interfaces/IMessageRepository.cs | 8 ++++++++ SPMS.Domain/Interfaces/IPushLogRepository.cs | 13 ++++++++++++ SPMS.Domain/Interfaces/IRepository.cs | 21 ++++++++++++++++++++ SPMS.Domain/Interfaces/IServiceRepository.cs | 12 +++++++++++ SPMS.Domain/Interfaces/IStatRepository.cs | 10 ++++++++++ SPMS.Domain/Interfaces/IUnitOfWork.cs | 9 +++++++++ 9 files changed, 103 insertions(+) create mode 100644 SPMS.Domain/Interfaces/IAdminRepository.cs create mode 100644 SPMS.Domain/Interfaces/IDeviceRepository.cs create mode 100644 SPMS.Domain/Interfaces/IFileRepository.cs create mode 100644 SPMS.Domain/Interfaces/IMessageRepository.cs create mode 100644 SPMS.Domain/Interfaces/IPushLogRepository.cs create mode 100644 SPMS.Domain/Interfaces/IRepository.cs create mode 100644 SPMS.Domain/Interfaces/IServiceRepository.cs create mode 100644 SPMS.Domain/Interfaces/IStatRepository.cs create mode 100644 SPMS.Domain/Interfaces/IUnitOfWork.cs diff --git a/SPMS.Domain/Interfaces/IAdminRepository.cs b/SPMS.Domain/Interfaces/IAdminRepository.cs new file mode 100644 index 0000000..efe572b --- /dev/null +++ b/SPMS.Domain/Interfaces/IAdminRepository.cs @@ -0,0 +1,10 @@ +using SPMS.Domain.Entities; + +namespace SPMS.Domain.Interfaces; + +public interface IAdminRepository : IRepository +{ + Task GetByEmailAsync(string email); + Task GetByAdminCodeAsync(string adminCode); + Task EmailExistsAsync(string email, long? excludeId = null); +} diff --git a/SPMS.Domain/Interfaces/IDeviceRepository.cs b/SPMS.Domain/Interfaces/IDeviceRepository.cs new file mode 100644 index 0000000..dfa8a24 --- /dev/null +++ b/SPMS.Domain/Interfaces/IDeviceRepository.cs @@ -0,0 +1,11 @@ +using SPMS.Domain.Entities; +using SPMS.Domain.Enums; + +namespace SPMS.Domain.Interfaces; + +public interface IDeviceRepository : IRepository +{ + Task GetByServiceAndTokenAsync(long serviceId, string deviceToken); + Task GetActiveCountByServiceAsync(long serviceId); + Task> GetByPlatformAsync(long serviceId, Platform platform); +} diff --git a/SPMS.Domain/Interfaces/IFileRepository.cs b/SPMS.Domain/Interfaces/IFileRepository.cs new file mode 100644 index 0000000..24d565a --- /dev/null +++ b/SPMS.Domain/Interfaces/IFileRepository.cs @@ -0,0 +1,9 @@ +using SPMS.Domain.Entities; + +namespace SPMS.Domain.Interfaces; + +public interface IFileRepository : IRepository +{ + Task GetByFileNameAsync(long serviceId, string fileName); + Task FileExistsAsync(long serviceId, string fileName); +} diff --git a/SPMS.Domain/Interfaces/IMessageRepository.cs b/SPMS.Domain/Interfaces/IMessageRepository.cs new file mode 100644 index 0000000..39781ae --- /dev/null +++ b/SPMS.Domain/Interfaces/IMessageRepository.cs @@ -0,0 +1,8 @@ +using SPMS.Domain.Entities; + +namespace SPMS.Domain.Interfaces; + +public interface IMessageRepository : IRepository +{ + Task GetByMessageCodeAsync(string messageCode); +} diff --git a/SPMS.Domain/Interfaces/IPushLogRepository.cs b/SPMS.Domain/Interfaces/IPushLogRepository.cs new file mode 100644 index 0000000..b76e021 --- /dev/null +++ b/SPMS.Domain/Interfaces/IPushLogRepository.cs @@ -0,0 +1,13 @@ +using SPMS.Domain.Entities; +using SPMS.Domain.Enums; + +namespace SPMS.Domain.Interfaces; + +public interface IPushLogRepository : IRepository +{ + Task<(IReadOnlyList Items, int TotalCount)> GetByMessageIdAsync( + long messageId, int page, int size, PushResult? status = null); + Task> GetFailedByMessageIdAsync(long messageId); + Task AddBatchAsync(IEnumerable logs); + Task GetCountByStatusAsync(long serviceId, long messageId, PushResult status); +} diff --git a/SPMS.Domain/Interfaces/IRepository.cs b/SPMS.Domain/Interfaces/IRepository.cs new file mode 100644 index 0000000..6b1797c --- /dev/null +++ b/SPMS.Domain/Interfaces/IRepository.cs @@ -0,0 +1,21 @@ +using System.Linq.Expressions; +using SPMS.Domain.Entities; + +namespace SPMS.Domain.Interfaces; + +public interface IRepository where T : BaseEntity +{ + Task GetByIdAsync(long id); + Task> GetAllAsync(); + Task> FindAsync(Expression> predicate); + Task<(IReadOnlyList Items, int TotalCount)> GetPagedAsync( + int page, int size, + Expression>? predicate = null, + Expression>? orderBy = null, + bool descending = true); + Task CountAsync(Expression>? predicate = null); + Task ExistsAsync(Expression> predicate); + Task AddAsync(T entity); + void Update(T entity); + void Delete(T entity); +} diff --git a/SPMS.Domain/Interfaces/IServiceRepository.cs b/SPMS.Domain/Interfaces/IServiceRepository.cs new file mode 100644 index 0000000..795dce8 --- /dev/null +++ b/SPMS.Domain/Interfaces/IServiceRepository.cs @@ -0,0 +1,12 @@ +using SPMS.Domain.Entities; +using SPMS.Domain.Enums; + +namespace SPMS.Domain.Interfaces; + +public interface IServiceRepository : IRepository +{ + Task GetByServiceCodeAsync(string serviceCode); + Task GetByApiKeyAsync(string apiKey); + Task GetByIdWithIpsAsync(long id); + Task> GetByStatusAsync(ServiceStatus status); +} diff --git a/SPMS.Domain/Interfaces/IStatRepository.cs b/SPMS.Domain/Interfaces/IStatRepository.cs new file mode 100644 index 0000000..df61ec6 --- /dev/null +++ b/SPMS.Domain/Interfaces/IStatRepository.cs @@ -0,0 +1,10 @@ +using SPMS.Domain.Entities; + +namespace SPMS.Domain.Interfaces; + +public interface IStatRepository : IRepository +{ + Task GetByServiceAndDateAsync(long serviceId, DateOnly date); + Task> GetByDateRangeAsync( + long serviceId, DateOnly startDate, DateOnly endDate); +} diff --git a/SPMS.Domain/Interfaces/IUnitOfWork.cs b/SPMS.Domain/Interfaces/IUnitOfWork.cs new file mode 100644 index 0000000..bd909ca --- /dev/null +++ b/SPMS.Domain/Interfaces/IUnitOfWork.cs @@ -0,0 +1,9 @@ +namespace SPMS.Domain.Interfaces; + +public interface IUnitOfWork : IDisposable +{ + Task SaveChangesAsync(CancellationToken cancellationToken = default); + Task BeginTransactionAsync(CancellationToken cancellationToken = default); + Task CommitTransactionAsync(CancellationToken cancellationToken = default); + Task RollbackTransactionAsync(CancellationToken cancellationToken = default); +} -- 2.45.1