50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
using IM_API.Tools;
|
|
|
|
namespace IM_API.Dtos
|
|
{
|
|
public class HubResponse<T>
|
|
{
|
|
public int Code { get; init; }
|
|
public string Method { get; init; }
|
|
public HubResponseType Type { get; init; }
|
|
public string Message { get; init; }
|
|
public T? Data { get; init; }
|
|
public HubResponse(string method)
|
|
{
|
|
Code = CodeDefine.SUCCESS.Code;
|
|
Message = CodeDefine.SUCCESS.Message;
|
|
Type = HubResponseType.ActionStatus;
|
|
Method = method;
|
|
}
|
|
public HubResponse(string method,T data)
|
|
{
|
|
Code = CodeDefine.SUCCESS.Code;
|
|
Message = CodeDefine.SUCCESS.Message;
|
|
Type = HubResponseType.ActionStatus;
|
|
Data = data;
|
|
Method = method;
|
|
}
|
|
public HubResponse(CodeDefine codedefine,string method)
|
|
{
|
|
Code = codedefine.Code;
|
|
Method = method;
|
|
Message = codedefine.Message;
|
|
Type = HubResponseType.ActionStatus;
|
|
}
|
|
public HubResponse(CodeDefine codeDefine, string method, HubResponseType type, T? data)
|
|
{
|
|
Code = codeDefine.Code;
|
|
Method = method;
|
|
Type = type;
|
|
Message = codeDefine.Message;
|
|
Data = data;
|
|
}
|
|
}
|
|
public enum HubResponseType
|
|
{
|
|
ChatMsg = 1, // 聊天内容
|
|
SystemNotice = 2, // 系统通知(如:申请好友成功)
|
|
ActionStatus = 3 // 状态变更(如:对方正在输入、已读回执)
|
|
}
|
|
}
|