initialize admin panel and necessry pages
This commit is contained in:
129
src/GreenHome.Application/Dtos/Admin/AdminDtos.cs
Normal file
129
src/GreenHome.Application/Dtos/Admin/AdminDtos.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using Domain = GreenHome.Domain;
|
||||
|
||||
namespace GreenHome.Application.Dtos.Admin;
|
||||
|
||||
// ==================== Dashboard ====================
|
||||
|
||||
public sealed class AdminDashboardDto
|
||||
{
|
||||
public int TotalUsers { get; set; }
|
||||
public int TotalDevices { get; set; }
|
||||
public int OnlineDevices { get; set; }
|
||||
public int OfflineDevices { get; set; }
|
||||
public int AlertsLast24h { get; set; }
|
||||
public int SmsLast7Days { get; set; }
|
||||
public int AiQueriesLast7Days { get; set; }
|
||||
|
||||
/// <summary>تعداد SMS بر اساس روز برای ۷ روز اخیر (sparkline)</summary>
|
||||
public IReadOnlyList<UsageDayDto> SmsDailyLast7Days { get; set; } = [];
|
||||
}
|
||||
|
||||
// ==================== Users ====================
|
||||
|
||||
public sealed class AdminUserFilter
|
||||
{
|
||||
public string? Search { get; set; }
|
||||
public int Page { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 20;
|
||||
}
|
||||
|
||||
public sealed class AdminUserListItemDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Family { get; set; } = string.Empty;
|
||||
public string Mobile { get; set; } = string.Empty;
|
||||
public Domain.UserRole Role { get; set; }
|
||||
public bool IsDisabled { get; set; }
|
||||
public int DeviceCount { get; set; }
|
||||
public DateTime? LastLoginAt { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
|
||||
public sealed class AdminUserDetailDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Family { get; set; } = string.Empty;
|
||||
public string Mobile { get; set; } = string.Empty;
|
||||
public Domain.UserRole Role { get; set; }
|
||||
public bool IsDisabled { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime? LastLoginAt { get; set; }
|
||||
public IReadOnlyList<AdminDeviceListItemDto> Devices { get; set; } = [];
|
||||
}
|
||||
|
||||
public sealed class ChangeUserRoleRequest
|
||||
{
|
||||
public Domain.UserRole Role { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ChangeUserStatusRequest
|
||||
{
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// نتیجه تغییر نقش/وضعیت کاربر توسط admin.
|
||||
/// </summary>
|
||||
public enum UserMutationOutcome
|
||||
{
|
||||
Ok,
|
||||
NotFound,
|
||||
ConflictSelf,
|
||||
ConflictLastAdmin
|
||||
}
|
||||
|
||||
// ==================== Devices ====================
|
||||
|
||||
public sealed class AdminDeviceFilter
|
||||
{
|
||||
public string? Search { get; set; }
|
||||
public int Page { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 20;
|
||||
}
|
||||
|
||||
public sealed class AdminDeviceListItemDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string DeviceName { get; set; } = string.Empty;
|
||||
public string Location { get; set; } = string.Empty;
|
||||
public string OwnerName { get; set; } = string.Empty;
|
||||
public string OwnerMobile { get; set; } = string.Empty;
|
||||
public bool IsOnline { get; set; }
|
||||
public DateTime? LastTelemetryAt { get; set; }
|
||||
public decimal? TemperatureC { get; set; }
|
||||
public decimal? HumidityPercent { get; set; }
|
||||
}
|
||||
|
||||
public sealed class AdminDeviceDetailDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string DeviceName { get; set; } = string.Empty;
|
||||
public string Location { get; set; } = string.Empty;
|
||||
public string OwnerName { get; set; } = string.Empty;
|
||||
public string OwnerFamily { get; set; } = string.Empty;
|
||||
public string OwnerMobile { get; set; } = string.Empty;
|
||||
public bool IsOnline { get; set; }
|
||||
public int MemberCount { get; set; }
|
||||
|
||||
public string? ProductType { get; set; }
|
||||
public string? Province { get; set; }
|
||||
public string? City { get; set; }
|
||||
public string? DevicePhoneNumber { get; set; }
|
||||
public int? UploadIntervalMin { get; set; }
|
||||
public int? RelayCount { get; set; }
|
||||
|
||||
public IReadOnlyList<TelemetryDto> LastTelemetry { get; set; } = [];
|
||||
}
|
||||
|
||||
// ==================== Usage ====================
|
||||
|
||||
public sealed class UsageDayDto
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public int SmsCount { get; set; }
|
||||
public int VoiceCallCount { get; set; }
|
||||
public int AiQueryCount { get; set; }
|
||||
public int AiTokenCount { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user