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); +}