feat: Add monitoring alerts skeleton and enhance worker with notifications
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
namespace CMSMicroservice.Application.Common.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// سرویس ارسال Alert و Notification
|
||||
/// برای ارسال اعلانهای مختلف از طریق کانالهای مختلف (Email, SMS, Slack, etc.)
|
||||
/// </summary>
|
||||
public interface IAlertService
|
||||
{
|
||||
/// <summary>
|
||||
/// ارسال Alert برای خطاهای Critical
|
||||
/// </summary>
|
||||
Task SendCriticalAlertAsync(string title, string message, Exception? exception = null, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال Alert برای Warning
|
||||
/// </summary>
|
||||
Task SendWarningAlertAsync(string title, string message, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال اعلان موفقیت
|
||||
/// </summary>
|
||||
Task SendSuccessNotificationAsync(string title, string message, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// سرویس ارسال Notification به کاربران
|
||||
/// برای ارسال پیامک، ایمیل و پوش به کاربران سیستم
|
||||
/// </summary>
|
||||
public interface IUserNotificationService
|
||||
{
|
||||
/// <summary>
|
||||
/// ارسال اعلان دریافت کمیسیون به کاربر
|
||||
/// </summary>
|
||||
Task SendCommissionReceivedNotificationAsync(
|
||||
long userId,
|
||||
decimal amount,
|
||||
int weekNumber,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال اعلان فعالسازی عضویت باشگاه
|
||||
/// </summary>
|
||||
Task SendClubActivationNotificationAsync(
|
||||
long userId,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال اعلان خطا در پرداخت
|
||||
/// </summary>
|
||||
Task SendPayoutErrorNotificationAsync(
|
||||
long userId,
|
||||
string errorMessage,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using CMSMicroservice.Domain.Enums;
|
||||
|
||||
namespace CMSMicroservice.Application.Common.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// سرویس محاسبه موقعیت در Binary Tree
|
||||
/// این سرویس مشخص میکند که کاربر جدید باید در کدام Leg (Left/Right) قرار بگیرد
|
||||
/// </summary>
|
||||
public interface INetworkPlacementService
|
||||
{
|
||||
/// <summary>
|
||||
/// محاسبه LegPosition برای کاربر جدید
|
||||
/// </summary>
|
||||
/// <param name="parentId">شناسه Parent در Network</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>
|
||||
/// - Left: اگر Parent فرزند چپ ندارد
|
||||
/// - Right: اگر Parent فرزند راست ندارد
|
||||
/// - null: اگر Parent هر دو Leg را دارد (Binary Tree پر است!)
|
||||
/// </returns>
|
||||
Task<NetworkLeg?> CalculateLegPositionAsync(long parentId, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// بررسی اینکه آیا Parent میتواند فرزند جدید بپذیرد
|
||||
/// </summary>
|
||||
/// <param name="parentId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>true اگر Parent کمتر از 2 فرزند دارد</returns>
|
||||
Task<bool> CanAcceptChildAsync(long parentId, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// پیدا کردن اولین Parent در شبکه که میتواند فرزند جدید بپذیرد
|
||||
/// (برای Auto-Placement در Binary Tree)
|
||||
/// </summary>
|
||||
/// <param name="rootParentId">شناسه Parent اصلی که از آن شروع میکنیم</param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns>شناسه Parent مناسب برای قرار گرفتن کاربر جدید</returns>
|
||||
Task<long?> FindAvailableParentAsync(long rootParentId, CancellationToken cancellationToken = default);
|
||||
}
|
||||
Reference in New Issue
Block a user