交换功能

This commit is contained in:
18631081161 2026-01-24 21:46:10 +08:00
parent 3bfcecd5bb
commit c3051968fe
3 changed files with 18 additions and 22 deletions

View File

@ -23,7 +23,7 @@ const ENV = {
}
// 当前环境 - 开发时使用 development打包时改为 production
const CURRENT_ENV = 'production'
const CURRENT_ENV = 'development'
// 导出配置
export const config = {

View File

@ -255,27 +255,6 @@ public class ChatController : ControllerBase
var userId = GetCurrentUserId();
var result = await _chatService.RespondExchangeAsync(userId, request);
// 通过 SignalR 推送交换响应给请求者
// 需要获取原始请求的发送者ID
var messages = await _chatService.GetMessagesAsync(userId, new GetMessagesRequest
{
SessionId = 0, // 这里需要从消息中获取
PageIndex = 1,
PageSize = 1
});
// 简化处理:直接通知所有相关用户
var messageResponse = new ChatMessageResponse
{
MessageId = result.ResultMessageId,
MessageType = request.IsAgreed ? 5 : 5, // ExchangeWeChatResult or ExchangePhotoResult
Content = request.IsAgreed ? "已同意交换" : "已拒绝交换",
ExtraData = result.ExchangedData,
IsRead = false,
CreateTime = DateTime.Now,
IsSelf = false
};
_logger.LogInformation("交换响应已处理: ResultMessageId={ResultMessageId}, IsAgreed={IsAgreed}",
result.ResultMessageId, request.IsAgreed);

View File

@ -1,3 +1,5 @@
using System.Text.Json.Serialization;
namespace XiangYi.Application.DTOs.Requests;
/// <summary>
@ -8,31 +10,37 @@ public class SendMessageRequest
/// <summary>
/// 会话ID
/// </summary>
[JsonPropertyName("sessionId")]
public long SessionId { get; set; }
/// <summary>
/// 接收者ID
/// </summary>
[JsonPropertyName("receiverId")]
public long ReceiverId { get; set; }
/// <summary>
/// 消息类型1文本 2语音 3图片
/// </summary>
[JsonPropertyName("messageType")]
public int MessageType { get; set; }
/// <summary>
/// 消息内容(文本消息)
/// </summary>
[JsonPropertyName("content")]
public string? Content { get; set; }
/// <summary>
/// 语音URL语音消息
/// </summary>
[JsonPropertyName("voiceUrl")]
public string? VoiceUrl { get; set; }
/// <summary>
/// 语音时长(秒)
/// </summary>
[JsonPropertyName("voiceDuration")]
public int? VoiceDuration { get; set; }
}
@ -44,11 +52,13 @@ public class ExchangeWeChatRequest
/// <summary>
/// 会话ID
/// </summary>
[JsonPropertyName("sessionId")]
public long SessionId { get; set; }
/// <summary>
/// 接收者ID
/// </summary>
[JsonPropertyName("receiverId")]
public long ReceiverId { get; set; }
}
@ -60,11 +70,13 @@ public class ExchangePhotoRequest
/// <summary>
/// 会话ID
/// </summary>
[JsonPropertyName("sessionId")]
public long SessionId { get; set; }
/// <summary>
/// 接收者ID
/// </summary>
[JsonPropertyName("receiverId")]
public long ReceiverId { get; set; }
}
@ -76,11 +88,13 @@ public class RespondExchangeRequest
/// <summary>
/// 原始请求消息ID
/// </summary>
[JsonPropertyName("requestMessageId")]
public long RequestMessageId { get; set; }
/// <summary>
/// 是否同意
/// </summary>
[JsonPropertyName("isAgreed")]
public bool IsAgreed { get; set; }
}
@ -92,15 +106,18 @@ public class GetMessagesRequest
/// <summary>
/// 会话ID
/// </summary>
[JsonPropertyName("sessionId")]
public long SessionId { get; set; }
/// <summary>
/// 页码
/// </summary>
[JsonPropertyName("pageIndex")]
public int PageIndex { get; set; } = 1;
/// <summary>
/// 每页大小
/// </summary>
[JsonPropertyName("pageSize")]
public int PageSize { get; set; } = 20;
}