后端:

新增好友请求事件和好友已添加事件
This commit is contained in:
2026-02-01 13:21:21 +08:00
committed by nanxun
40 changed files with 550 additions and 194 deletions
+47
View File
@@ -0,0 +1,47 @@
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;
}
public HubResponse(string method,T data)
{
Code = CodeDefine.SUCCESS.Code;
Message = CodeDefine.SUCCESS.Message;
Type = HubResponseType.ActionStatus;
Data = data;
}
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 // 状态变更(如:对方正在输入、已读回执)
}
}
+5 -3
View File
@@ -1,10 +1,12 @@
namespace IM_API.Dtos
using IM_API.Models;
namespace IM_API.Dtos
{
public record MessageBaseDto
{
// 使用 { get; init; } 确保对象创建后不可修改,且支持无参构造
public string Type { get; init; } = default!;
public string ChatType { get; init; } = default!;
public MessageMsgType Type { get; init; } = default!;
public ChatType ChatType { get; init; } = default!;
public string? MsgId { get; init; }
public int SenderId { get; init; }
public int ReceiverId { get; init; }