refactor: reorganize Application layer into folder structure
This commit is contained in:
39
src/GreenHome.Application/Interfaces/IAIQueryService.cs
Normal file
39
src/GreenHome.Application/Interfaces/IAIQueryService.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using GreenHome.Domain;
|
||||
|
||||
namespace GreenHome.Application;
|
||||
|
||||
/// <summary>
|
||||
/// Service for managing AI queries and their history
|
||||
/// </summary>
|
||||
public interface IAIQueryService
|
||||
{
|
||||
/// <summary>
|
||||
/// Saves an AI query to the database
|
||||
/// </summary>
|
||||
Task<AIQuery> SaveQueryAsync(AIQuery query, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Gets AI query history for a specific device
|
||||
/// </summary>
|
||||
Task<List<AIQuery>> GetDeviceQueriesAsync(int deviceId, int take = 50, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Gets AI query history for a specific user
|
||||
/// </summary>
|
||||
Task<List<AIQuery>> GetUserQueriesAsync(int userId, int take = 50, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Gets total token usage for a device
|
||||
/// </summary>
|
||||
Task<int> GetDeviceTotalTokensAsync(int deviceId, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Gets total token usage for a user
|
||||
/// </summary>
|
||||
Task<int> GetUserTotalTokensAsync(int userId, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Gets AI query statistics (totals, averages, today's usage)
|
||||
/// </summary>
|
||||
Task<AIQueryStats> GetStatsAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface IAlertConditionService
|
||||
{
|
||||
Task<IReadOnlyList<AlertConditionDto>> GetByDeviceIdAsync(int deviceId, CancellationToken cancellationToken);
|
||||
Task<AlertConditionDto?> GetByIdAsync(int id, CancellationToken cancellationToken);
|
||||
Task<int> CreateAsync(CreateAlertConditionRequest request, CancellationToken cancellationToken);
|
||||
Task UpdateAsync(UpdateAlertConditionRequest request, CancellationToken cancellationToken);
|
||||
Task DeleteAsync(int id, CancellationToken cancellationToken);
|
||||
Task<bool> ToggleEnabledAsync(int id, bool isEnabled, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت شرایط هشدار رلهای (notificationType > 0) برای یک دستگاه
|
||||
/// </summary>
|
||||
Task<IReadOnlyList<RelayConditionDto>> GetRelayConditionsAsync(int deviceId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت شرایط هشدار رلهای که بعد از تاریخ مشخصی بهروزرسانی شدهاند
|
||||
/// اگر هیچ رکوردی بهروزرسانی نشده باشد، لیست خالی برمیگرداند
|
||||
/// </summary>
|
||||
Task<IReadOnlyList<RelayConditionDto>> GetUpdatedRelayConditionsAsync(int deviceId, DateTime? lastUpdateDate, CancellationToken cancellationToken);
|
||||
|
||||
Task<bool> HasUpdatedConditionsAsync(int deviceId, DateTime? lastUpdateDate, CancellationToken cancellationToken);
|
||||
}
|
||||
8
src/GreenHome.Application/Interfaces/IAlertLogService.cs
Normal file
8
src/GreenHome.Application/Interfaces/IAlertLogService.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface IAlertLogService
|
||||
{
|
||||
Task<PagedResult<AlertLogDto>> GetAlertLogsAsync(AlertLogFilter filter, CancellationToken cancellationToken);
|
||||
Task<AlertLogDto?> GetAlertLogByIdAsync(int id, CancellationToken cancellationToken);
|
||||
Task<int> CreateAlertLogAsync(AlertLogDto dto, CancellationToken cancellationToken);
|
||||
}
|
||||
7
src/GreenHome.Application/Interfaces/IAlertService.cs
Normal file
7
src/GreenHome.Application/Interfaces/IAlertService.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface IAlertService
|
||||
{
|
||||
Task<AlertCheckResult?> CheckAndSendAlertsAsync(int deviceId, TelemetryDto telemetry, CancellationToken cancellationToken);
|
||||
Task SendPowerOutageAlertAsync(int deviceId, CancellationToken cancellationToken);
|
||||
}
|
||||
8
src/GreenHome.Application/Interfaces/IAuthService.cs
Normal file
8
src/GreenHome.Application/Interfaces/IAuthService.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface IAuthService
|
||||
{
|
||||
Task<SendCodeResponse> SendVerificationCodeAsync(SendCodeRequest request, CancellationToken cancellationToken);
|
||||
Task<VerifyCodeResponse> VerifyCodeAsync(VerifyCodeRequest request, CancellationToken cancellationToken);
|
||||
Task<bool> CanResendCodeAsync(string mobile, CancellationToken cancellationToken);
|
||||
}
|
||||
11
src/GreenHome.Application/Interfaces/IChecklistService.cs
Normal file
11
src/GreenHome.Application/Interfaces/IChecklistService.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface IChecklistService
|
||||
{
|
||||
Task<ChecklistDto?> GetActiveChecklistByDeviceIdAsync(int deviceId, CancellationToken cancellationToken);
|
||||
Task<List<ChecklistDto>> GetChecklistsByDeviceIdAsync(int deviceId, CancellationToken cancellationToken);
|
||||
Task<ChecklistDto?> GetChecklistByIdAsync(int id, CancellationToken cancellationToken);
|
||||
Task<int> CreateChecklistAsync(CreateChecklistRequest request, CancellationToken cancellationToken);
|
||||
Task<List<ChecklistCompletionDto>> GetCompletionsByChecklistIdAsync(int checklistId, CancellationToken cancellationToken);
|
||||
Task<int> CompleteChecklistAsync(CompleteChecklistRequest request, CancellationToken cancellationToken);
|
||||
}
|
||||
16
src/GreenHome.Application/Interfaces/IDailyReportService.cs
Normal file
16
src/GreenHome.Application/Interfaces/IDailyReportService.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface IDailyReportService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or generates a daily analysis report for a device on a specific date
|
||||
/// </summary>
|
||||
/// <param name="request">Request containing device ID and Persian date</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Daily report with AI analysis</returns>
|
||||
Task<DailyReportResponse> GetOrCreateDailyReportAsync(DailyReportRequest request, CancellationToken cancellationToken);
|
||||
|
||||
Task<DailyReportResponse> GetWeeklyAnalysisAsync(WeeklyAnalysisRequest request, CancellationToken cancellationToken);
|
||||
|
||||
Task<DailyReportResponse> GetMonthlyAnalysisAsync(MonthlyAnalysisRequest request, CancellationToken cancellationToken);
|
||||
}
|
||||
13
src/GreenHome.Application/Interfaces/IDevicePostService.cs
Normal file
13
src/GreenHome.Application/Interfaces/IDevicePostService.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface IDevicePostService
|
||||
{
|
||||
Task<PagedResult<DevicePostDto>> GetPostsAsync(DevicePostFilter filter, CancellationToken cancellationToken);
|
||||
Task<DevicePostDto?> GetPostByIdAsync(int id, CancellationToken cancellationToken);
|
||||
Task<int> CreatePostAsync(CreateDevicePostRequest request, CancellationToken cancellationToken);
|
||||
Task UpdatePostAsync(UpdateDevicePostRequest request, CancellationToken cancellationToken);
|
||||
Task DeletePostAsync(int id, CancellationToken cancellationToken);
|
||||
Task<int> AddImageToPostAsync(int postId, string fileName, string filePath, string contentType, long fileSize, CancellationToken cancellationToken);
|
||||
Task DeleteImageAsync(int imageId, CancellationToken cancellationToken);
|
||||
Task<bool> CanUserAccessDeviceAsync(int userId, int deviceId, CancellationToken cancellationToken);
|
||||
}
|
||||
10
src/GreenHome.Application/Interfaces/IDeviceService.cs
Normal file
10
src/GreenHome.Application/Interfaces/IDeviceService.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface IDeviceService
|
||||
{
|
||||
Task<int> AddDeviceAsync(DeviceDto dto, CancellationToken cancellationToken);
|
||||
Task<IReadOnlyList<DeviceDto>> ListAsync(CancellationToken cancellationToken);
|
||||
Task<DeviceDto> GetDeviceId(string deviceName, CancellationToken cancellationToken);
|
||||
Task<IReadOnlyList<DeviceDto>> GetUserDevicesAsync(int userId, CancellationToken cancellationToken);
|
||||
Task<PagedResult<DeviceDto>> GetDevicesAsync(DeviceFilter filter, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface IDeviceSettingsService
|
||||
{
|
||||
Task<DeviceSettingsDto?> GetByDeviceIdAsync(int deviceId, CancellationToken cancellationToken);
|
||||
Task<int> CreateAsync(DeviceSettingsDto dto, CancellationToken cancellationToken);
|
||||
Task UpdateAsync(DeviceSettingsDto dto, CancellationToken cancellationToken);
|
||||
}
|
||||
22
src/GreenHome.Application/Interfaces/IDeviceTokenService.cs
Normal file
22
src/GreenHome.Application/Interfaces/IDeviceTokenService.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
/// <summary>
|
||||
/// سرویس مدیریت توکن و تنظیمات دستگاه
|
||||
/// </summary>
|
||||
public interface IDeviceTokenService
|
||||
{
|
||||
/// <summary>
|
||||
/// دریافت فاصله زمانی آپلود بر اساس شماره تلفن یا شناسه دستگاه
|
||||
/// </summary>
|
||||
Task<GetUploadIntervalResponse> GetUploadIntervalAsync(GetUploadIntervalRequest request, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// درخواست توکن دستگاه (تولید و ارسال کد)
|
||||
/// </summary>
|
||||
Task<RequestDeviceTokenResponse> RequestDeviceTokenAsync(RequestDeviceTokenRequest request, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// تایید توکن دستگاه (ارسال تنظیمات)
|
||||
/// </summary>
|
||||
Task<VerifyDeviceTokenResponse> VerifyDeviceTokenAsync(VerifyDeviceTokenRequest request, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface IMonthlyReportService
|
||||
{
|
||||
Task<MonthlyReportDto> GetMonthlyReportAsync(int deviceId, int year, int month, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
/// <summary>
|
||||
/// سرویس لاگ قطع و وصل برق دستگاه
|
||||
/// </summary>
|
||||
public interface IPowerOutageLogService
|
||||
{
|
||||
/// <summary>
|
||||
/// ثبت یک رویداد قطع یا وصل برق
|
||||
/// </summary>
|
||||
Task LogPowerChangeAsync(int deviceId, byte previousPower, byte currentPower, DateTime timestampUtc, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست رویدادهای برق یک دستگاه
|
||||
/// </summary>
|
||||
Task<PagedResult<PowerOutageLogDto>> ListAsync(int deviceId, PowerOutageFilter filter, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// مهاجرت دادههای قدیمی از جدول Telemetry به PowerOutageLogs
|
||||
/// تشخیص تغییرات Power در رکوردهای متوالی هر دستگاه
|
||||
/// </summary>
|
||||
Task<int> MigrateFromTelemetryAsync(int? deviceId, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface ISunCalculatorService
|
||||
{
|
||||
/// <summary>
|
||||
/// بررسی میکند که آیا زمان داده شده در روز است یا شب
|
||||
/// </summary>
|
||||
/// <param name="dateTime">زمان UTC</param>
|
||||
/// <param name="latitude">عرض جغرافیایی</param>
|
||||
/// <param name="longitude">طول جغرافیایی</param>
|
||||
/// <returns>true اگر روز باشد، false اگر شب باشد</returns>
|
||||
bool IsDaytime(DateTime dateTime, decimal latitude, decimal longitude);
|
||||
}
|
||||
10
src/GreenHome.Application/Interfaces/ITelemetryService.cs
Normal file
10
src/GreenHome.Application/Interfaces/ITelemetryService.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface ITelemetryService
|
||||
{
|
||||
Task<int> AddAsync(TelemetryDto dto, CancellationToken cancellationToken);
|
||||
Task<PagedResult<TelemetryDto>> ListAsync(TelemetryFilter filter, CancellationToken cancellationToken);
|
||||
Task<TelemetryMinMax> GetMinMaxAsync(int deviceId, DateTime? startUtc, DateTime? endUtc, CancellationToken cancellationToken);
|
||||
Task<IReadOnlyList<DayCount>> GetMonthDaysAsync(int deviceId, int persianYear, int persianMonth, CancellationToken cancellationToken);
|
||||
Task<IReadOnlyList<int>> GetActiveMonthsAsync(int deviceId, int persianYear, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace GreenHome.Application;
|
||||
|
||||
public interface IUserDailyReportService
|
||||
{
|
||||
Task<PagedResult<UserDailyReportDto>> GetReportsAsync(UserDailyReportFilter filter, CancellationToken cancellationToken);
|
||||
Task<UserDailyReportDto?> GetReportByIdAsync(int id, CancellationToken cancellationToken);
|
||||
Task<int> CreateReportAsync(CreateUserDailyReportRequest request, CancellationToken cancellationToken);
|
||||
Task UpdateReportAsync(UpdateUserDailyReportRequest request, CancellationToken cancellationToken);
|
||||
Task DeleteReportAsync(int id, CancellationToken cancellationToken);
|
||||
Task<int> AddImageToReportAsync(int reportId, string fileName, string filePath, string contentType, long fileSize, string? description, CancellationToken cancellationToken);
|
||||
Task DeleteImageAsync(int imageId, CancellationToken cancellationToken);
|
||||
}
|
||||
Reference in New Issue
Block a user