1、优化消息排序逻辑 2、新增加载历史消息 3、修复已知问题 后端: 1、优化消息排序逻辑 2、增加用户信息缓存机制 3、修改日期类型为DateTimeOffset改善时区信息丢失问题 3、修复了已知问题 数据库: 1、新增SequenceId字段用于消息排序 2、新增ClientMsgId字段用于客户端消息回执
57 lines
2.0 KiB
C#
57 lines
2.0 KiB
C#
using IM_API.Dtos;
|
|
using IM_API.Interface.Services;
|
|
using IM_API.Models;
|
|
using IM_API.VOs.Conversation;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Security.Claims;
|
|
|
|
namespace IM_API.Controllers
|
|
{
|
|
[Route("api/[controller]/[action]")]
|
|
[Authorize]
|
|
[ApiController]
|
|
public class ConversationController : ControllerBase
|
|
{
|
|
private readonly IConversationService _conversationSerivice;
|
|
private readonly ILogger<ConversationController> _logger;
|
|
public ConversationController(IConversationService conversationSerivice, ILogger<ConversationController> logger)
|
|
{
|
|
_conversationSerivice = conversationSerivice;
|
|
_logger = logger;
|
|
}
|
|
[HttpGet]
|
|
public async Task<IActionResult> List()
|
|
{
|
|
var userIdStr = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
|
var list = await _conversationSerivice.GetConversationsAsync(int.Parse(userIdStr));
|
|
var res = new BaseResponse<List<ConversationVo>>(list);
|
|
return Ok(res);
|
|
}
|
|
[HttpGet]
|
|
public async Task<IActionResult> Get([FromQuery]int conversationId)
|
|
{
|
|
var userIdStr = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
|
var conversation = await _conversationSerivice.GetConversationByIdAsync(int.Parse(userIdStr), conversationId);
|
|
var res = new BaseResponse<ConversationVo>(conversation);
|
|
return Ok(res);
|
|
}
|
|
[HttpPost]
|
|
public async Task<IActionResult> Clear()
|
|
{
|
|
var userIdStr = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
|
await _conversationSerivice.ClearConversationsAsync(int.Parse(userIdStr));
|
|
return Ok(new BaseResponse<object?>());
|
|
}
|
|
[HttpPost]
|
|
public async Task<IActionResult> Delete(int cid)
|
|
{
|
|
await _conversationSerivice.DeleteConversationAsync(cid);
|
|
return Ok(new BaseResponse<object?>());
|
|
}
|
|
|
|
|
|
}
|
|
}
|