feat: Domain Interface 정의 — Repository, UnitOfWork (#12) #13
10
SPMS.Domain/Interfaces/IAdminRepository.cs
Normal file
10
SPMS.Domain/Interfaces/IAdminRepository.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
using SPMS.Domain.Entities;
|
||||||
|
|
||||||
|
namespace SPMS.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IAdminRepository : IRepository<Admin>
|
||||||
|
{
|
||||||
|
Task<Admin?> GetByEmailAsync(string email);
|
||||||
|
Task<Admin?> GetByAdminCodeAsync(string adminCode);
|
||||||
|
Task<bool> EmailExistsAsync(string email, long? excludeId = null);
|
||||||
|
}
|
||||||
11
SPMS.Domain/Interfaces/IDeviceRepository.cs
Normal file
11
SPMS.Domain/Interfaces/IDeviceRepository.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
using SPMS.Domain.Entities;
|
||||||
|
using SPMS.Domain.Enums;
|
||||||
|
|
||||||
|
namespace SPMS.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IDeviceRepository : IRepository<Device>
|
||||||
|
{
|
||||||
|
Task<Device?> GetByServiceAndTokenAsync(long serviceId, string deviceToken);
|
||||||
|
Task<int> GetActiveCountByServiceAsync(long serviceId);
|
||||||
|
Task<IReadOnlyList<Device>> GetByPlatformAsync(long serviceId, Platform platform);
|
||||||
|
}
|
||||||
9
SPMS.Domain/Interfaces/IFileRepository.cs
Normal file
9
SPMS.Domain/Interfaces/IFileRepository.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
using SPMS.Domain.Entities;
|
||||||
|
|
||||||
|
namespace SPMS.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IFileRepository : IRepository<FileEntity>
|
||||||
|
{
|
||||||
|
Task<FileEntity?> GetByFileNameAsync(long serviceId, string fileName);
|
||||||
|
Task<bool> FileExistsAsync(long serviceId, string fileName);
|
||||||
|
}
|
||||||
8
SPMS.Domain/Interfaces/IMessageRepository.cs
Normal file
8
SPMS.Domain/Interfaces/IMessageRepository.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
using SPMS.Domain.Entities;
|
||||||
|
|
||||||
|
namespace SPMS.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IMessageRepository : IRepository<Message>
|
||||||
|
{
|
||||||
|
Task<Message?> GetByMessageCodeAsync(string messageCode);
|
||||||
|
}
|
||||||
13
SPMS.Domain/Interfaces/IPushLogRepository.cs
Normal file
13
SPMS.Domain/Interfaces/IPushLogRepository.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
using SPMS.Domain.Entities;
|
||||||
|
using SPMS.Domain.Enums;
|
||||||
|
|
||||||
|
namespace SPMS.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IPushLogRepository : IRepository<PushSendLog>
|
||||||
|
{
|
||||||
|
Task<(IReadOnlyList<PushSendLog> Items, int TotalCount)> GetByMessageIdAsync(
|
||||||
|
long messageId, int page, int size, PushResult? status = null);
|
||||||
|
Task<IReadOnlyList<PushSendLog>> GetFailedByMessageIdAsync(long messageId);
|
||||||
|
Task AddBatchAsync(IEnumerable<PushSendLog> logs);
|
||||||
|
Task<int> GetCountByStatusAsync(long serviceId, long messageId, PushResult status);
|
||||||
|
}
|
||||||
21
SPMS.Domain/Interfaces/IRepository.cs
Normal file
21
SPMS.Domain/Interfaces/IRepository.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using SPMS.Domain.Entities;
|
||||||
|
|
||||||
|
namespace SPMS.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IRepository<T> where T : BaseEntity
|
||||||
|
{
|
||||||
|
Task<T?> GetByIdAsync(long id);
|
||||||
|
Task<IReadOnlyList<T>> GetAllAsync();
|
||||||
|
Task<IReadOnlyList<T>> FindAsync(Expression<Func<T, bool>> predicate);
|
||||||
|
Task<(IReadOnlyList<T> Items, int TotalCount)> GetPagedAsync(
|
||||||
|
int page, int size,
|
||||||
|
Expression<Func<T, bool>>? predicate = null,
|
||||||
|
Expression<Func<T, object>>? orderBy = null,
|
||||||
|
bool descending = true);
|
||||||
|
Task<int> CountAsync(Expression<Func<T, bool>>? predicate = null);
|
||||||
|
Task<bool> ExistsAsync(Expression<Func<T, bool>> predicate);
|
||||||
|
Task AddAsync(T entity);
|
||||||
|
void Update(T entity);
|
||||||
|
void Delete(T entity);
|
||||||
|
}
|
||||||
12
SPMS.Domain/Interfaces/IServiceRepository.cs
Normal file
12
SPMS.Domain/Interfaces/IServiceRepository.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
using SPMS.Domain.Entities;
|
||||||
|
using SPMS.Domain.Enums;
|
||||||
|
|
||||||
|
namespace SPMS.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IServiceRepository : IRepository<Service>
|
||||||
|
{
|
||||||
|
Task<Service?> GetByServiceCodeAsync(string serviceCode);
|
||||||
|
Task<Service?> GetByApiKeyAsync(string apiKey);
|
||||||
|
Task<Service?> GetByIdWithIpsAsync(long id);
|
||||||
|
Task<IReadOnlyList<Service>> GetByStatusAsync(ServiceStatus status);
|
||||||
|
}
|
||||||
10
SPMS.Domain/Interfaces/IStatRepository.cs
Normal file
10
SPMS.Domain/Interfaces/IStatRepository.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
using SPMS.Domain.Entities;
|
||||||
|
|
||||||
|
namespace SPMS.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IStatRepository : IRepository<DailyStat>
|
||||||
|
{
|
||||||
|
Task<DailyStat?> GetByServiceAndDateAsync(long serviceId, DateOnly date);
|
||||||
|
Task<IReadOnlyList<DailyStat>> GetByDateRangeAsync(
|
||||||
|
long serviceId, DateOnly startDate, DateOnly endDate);
|
||||||
|
}
|
||||||
9
SPMS.Domain/Interfaces/IUnitOfWork.cs
Normal file
9
SPMS.Domain/Interfaces/IUnitOfWork.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace SPMS.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IUnitOfWork : IDisposable
|
||||||
|
{
|
||||||
|
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task<IDisposable> BeginTransactionAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task CommitTransactionAsync(CancellationToken cancellationToken = default);
|
||||||
|
Task RollbackTransactionAsync(CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user