feat: Domain Interface 정의 — Repository, UnitOfWork (#12)
Some checks failed
SPMS_API/pipeline/head There was a failure building this commit

Reviewed-on: https://git.ipstein.myds.me/SPMS/SPMS_API/pulls/13
This commit is contained in:
김선규 2026-02-09 04:51:52 +00:00
commit 5d8e30494e
9 changed files with 103 additions and 0 deletions

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

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

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

View File

@ -0,0 +1,8 @@
using SPMS.Domain.Entities;
namespace SPMS.Domain.Interfaces;
public interface IMessageRepository : IRepository<Message>
{
Task<Message?> GetByMessageCodeAsync(string messageCode);
}

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

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

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

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

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