namespace JiaZhiQuan.Common.Hubs
{
    /// <summary>
    /// 服务端返回的格式
    /// </summary>
    public class ServerResultDTO
    {
        public ServerResultDTO(ResultMessageEvent messageEvent, ResultMessageStatus messageStatus, string message)
        {
            Event = messageEvent;
            MessageStatus = messageStatus;
            Message = message;
        }

        public ServerResultDTO(ResultMessageEvent messageEvent, ResultMessageStatus messageStatus, string message, object data)
        {
            Event = messageEvent;
            MessageStatus = messageStatus;
            Message = message;
            Data = data;
        }

        /// <summary>
        /// 执行结果
        /// </summary>
        public ResultMessageStatus MessageStatus { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 数据
        /// </summary>
        public object Data { get; set; }

        /// <summary>
        /// 消息事件类型
        /// </summary>
        public ResultMessageEvent Event { get; set; }

        public static ServerResultDTO Success(ResultMessageEvent messageEvent, string message)
        {
            return new ServerResultDTO(messageEvent, ResultMessageStatus.Success, message);
        }

        public static ServerResultDTO Success(ResultMessageEvent messageEvent, string message, object data)
        {
            return new ServerResultDTO(messageEvent, ResultMessageStatus.Success, message, data);
        }

        public static ServerResultDTO Error(ResultMessageEvent messageEvent, string message)
        {
            return new ServerResultDTO(messageEvent, ResultMessageStatus.Error, message);
        }

        public static ServerResultDTO Error(ResultMessageEvent messageEvent, string message, object data)
        {
            return new ServerResultDTO(messageEvent, ResultMessageStatus.Error, message, data);
        }
    }

    public enum ResultMessageStatus
    {
        Success,
        Error
    }
    public enum ResultMessageEvent
    {
        /// <summary>
        /// 连接SignalR
        /// </summary>
        Connection = 0,

        /// <summary>
        /// 创建聊天
        /// </summary>
        CreateChat = 1,

        /// <summary>
        /// 发送消息
        /// </summary>
        SendMessage = 2,

        /// <summary>
        /// 接收消息
        /// </summary>
        ReceiveMessage = 3,

        /// <summary>
        /// 用户聊天列表
        /// </summary>
        UserChatList = 4,

        /// <summary>
        /// 聊天记录
        /// </summary>
        ChatHistory = 5,

        /// <summary>
        /// 已读
        /// </summary>
        Read = 6,

        /// <summary>
        /// 撤回
        /// </summary>
        Withdraw = 7,

        /// <summary>
        /// 置顶
        /// </summary>
        TopChat = 8,

        /// <summary>
        /// 隐藏聊天
        /// </summary>
        HiddenChat = 9,

        /// <summary>
        /// 免打扰聊天
        /// </summary>
        MuteChat = 10,

        /// <summary>
        /// 系统通知
        /// </summary>
        SystemNotice = 11,

        /// <summary>
        /// 用户的商品
        /// </summary>
        ChatUserGoods = 12,

        /// <summary>
        /// 用户的订单
        /// </summary>
        ChatUserOrder = 13,
    }
}
