修改消息记录和发送消息接口返回格式
This commit is contained in:
parent
bfa0f8cc9c
commit
fba8540c15
|
|
@ -10,6 +10,7 @@ using HuanMeng.Utility;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
@ -137,9 +138,9 @@ namespace HuanMeng.MiaoYu.Code.Chat
|
||||||
/// <param name="message">消息内容</param>
|
/// <param name="message">消息内容</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="ArgumentException"></exception>
|
/// <exception cref="ArgumentException"></exception>
|
||||||
public async Task<BaseResponse<List<ChatMessageDto>>> Message(int characterId, string message)
|
public async Task<BaseResponse<ChatMessageDataDto>> Message(int characterId, string message)
|
||||||
{
|
{
|
||||||
|
ChatMessageDataDto chatListDto = new ChatMessageDataDto();
|
||||||
List<ChatMessageDto> chatMessageDtos = new List<ChatMessageDto>();
|
List<ChatMessageDto> chatMessageDtos = new List<ChatMessageDto>();
|
||||||
var charact = MiaoYuCache.CharacterList.FirstOrDefault(it => it.Id == characterId);
|
var charact = MiaoYuCache.CharacterList.FirstOrDefault(it => it.Id == characterId);
|
||||||
if (charact == null)
|
if (charact == null)
|
||||||
|
|
@ -158,7 +159,8 @@ namespace HuanMeng.MiaoYu.Code.Chat
|
||||||
UserIcon = charact.IconImage
|
UserIcon = charact.IconImage
|
||||||
};
|
};
|
||||||
chatMessageDtos.Add(chatMessage);
|
chatMessageDtos.Add(chatMessage);
|
||||||
return new BaseResponse<List<ChatMessageDto>>(ResonseCode.Success, "", chatMessageDtos);
|
chatListDto.ChatList = chatMessageDtos;
|
||||||
|
return new BaseResponse<ChatMessageDataDto>(ResonseCode.Success, "", chatListDto);
|
||||||
}
|
}
|
||||||
//if(timeStamp.)
|
//if(timeStamp.)
|
||||||
var userChatSession = await Dao.daoDbMiaoYu.context.T_User_Chat.Where(it => it.CharacterId == characterId && it.UserId == _UserId && !it.IsDelete).FirstOrDefaultAsync();
|
var userChatSession = await Dao.daoDbMiaoYu.context.T_User_Chat.Where(it => it.CharacterId == characterId && it.UserId == _UserId && !it.IsDelete).FirstOrDefaultAsync();
|
||||||
|
|
@ -222,8 +224,8 @@ namespace HuanMeng.MiaoYu.Code.Chat
|
||||||
UpdateTime = DateTime.Now,
|
UpdateTime = DateTime.Now,
|
||||||
UserId = _UserId,
|
UserId = _UserId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region 调用api
|
#region 调用api
|
||||||
ClaudeChatChatParams baseChatParams = new ClaudeChatChatParams();
|
ClaudeChatChatParams baseChatParams = new ClaudeChatChatParams();
|
||||||
|
|
@ -271,7 +273,10 @@ namespace HuanMeng.MiaoYu.Code.Chat
|
||||||
Id = t_Chat.Id
|
Id = t_Chat.Id
|
||||||
};
|
};
|
||||||
chatMessageDtos.Add(chatMessageDto);
|
chatMessageDtos.Add(chatMessageDto);
|
||||||
return new BaseResponse<List<ChatMessageDto>>(ResonseCode.Success, "", chatMessageDtos);
|
chatListDto.ChatList = chatMessageDtos;
|
||||||
|
chatListDto.LastMessageId = t_Chat1.Id;
|
||||||
|
chatListDto.RemainingChatCount = 999;
|
||||||
|
return new BaseResponse<ChatMessageDataDto>(ResonseCode.Success, "", chatListDto);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除聊天记录
|
/// 删除聊天记录
|
||||||
|
|
|
||||||
|
|
@ -94,16 +94,29 @@ namespace HuanMeng.MiaoYu.Model.Dto.Chat
|
||||||
// public string LabelName { get; set; }
|
// public string LabelName { get; set; }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 聊天列表
|
/// 聊天列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ChatListDto
|
public class ChatMessageDataDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 聊天列表
|
/// 聊天列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ChatMessageDto> ChatList { get; set; }
|
public List<ChatMessageDto> ChatList { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 剩余聊天次数
|
||||||
|
/// </summary>
|
||||||
|
public int RemainingChatCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户发送的消息Id
|
||||||
|
/// </summary>
|
||||||
|
public int LastMessageId { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -68,13 +68,13 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<BaseResponse<ChatListDto>> GetChatInfo(int characterId)
|
public async Task<BaseResponse<List<ChatMessageDto>>> GetChatInfo(int characterId)
|
||||||
{
|
{
|
||||||
ChatListDto chatListDto = new ChatListDto();
|
|
||||||
ChatBLL chatBLL = new ChatBLL(ServiceProvider);
|
ChatBLL chatBLL = new ChatBLL(ServiceProvider);
|
||||||
var list = await chatBLL.GetChatMessage(characterId);
|
var list = await chatBLL.GetChatMessage(characterId);
|
||||||
chatListDto.ChatList = list.Data;
|
|
||||||
return new BaseResponse<ChatListDto>(ResonseCode.Success, "", chatListDto);
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -83,7 +83,7 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers
|
||||||
/// <param name="requestMessage"></param>
|
/// <param name="requestMessage"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<BaseResponse<List<ChatMessageDto>>> SendMessage([FromBody] RequestMessage requestMessage)
|
public async Task<BaseResponse<ChatMessageDataDto>> SendMessage([FromBody] RequestMessage requestMessage)
|
||||||
{
|
{
|
||||||
ChatBLL chatBLL = new ChatBLL(ServiceProvider);
|
ChatBLL chatBLL = new ChatBLL(ServiceProvider);
|
||||||
var obj = await chatBLL.Message(requestMessage.CharacterId, requestMessage.Message);
|
var obj = await chatBLL.Message(requestMessage.CharacterId, requestMessage.Message);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user