using System;

namespace NPP.SmartSchedue.Api.Contracts.Services.Notification.Output;

/// <summary>
/// 系统消息状态输出模型
/// </summary>
public class SystemMessageStatusOutput
{
    /// <summary>
    /// 操作是否成功
    /// </summary>
    public bool Success { get; set; }

    /// <summary>
    /// 操作结果消息
    /// </summary>
    public string Message { get; set; } = "";

    /// <summary>
    /// 影响的消息数量
    /// </summary>
    public int AffectedCount { get; set; }

    /// <summary>
    /// 操作时间
    /// </summary>
    public DateTime OperationTime { get; set; }

    /// <summary>
    /// 人员ID
    /// </summary>
    public long PersonnelId { get; set; }

    /// <summary>
    /// 创建成功结果
    /// </summary>
    public static SystemMessageStatusOutput CreateSuccess(long personnelId, int affectedCount, string message = "操作成功")
    {
        return new SystemMessageStatusOutput
        {
            Success = true,
            Message = message,
            AffectedCount = affectedCount,
            PersonnelId = personnelId,
            OperationTime = DateTime.Now
        };
    }

    /// <summary>
    /// 创建失败结果
    /// </summary>
    public static SystemMessageStatusOutput CreateFailure(long personnelId, string errorMessage)
    {
        return new SystemMessageStatusOutput
        {
            Success = false,
            Message = errorMessage,
            AffectedCount = 0,
            PersonnelId = personnelId,
            OperationTime = DateTime.Now
        };
    }
}