using System.Threading.Tasks; using GxPress.Auth; using GxPress.Common.Page; using GxPress.Repository.Interface; using GxPress.Request.App.ChatRecord; using GxPress.Result.App.ChatRecord; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; namespace GxPress.Api.AppControllers { /// /// 聊天信息 /// [Route("api/app/chat-record")] [ApiController] [Authorize] public class ChatRecordController : ControllerBase { private readonly ILogger _logger; private readonly IChatRecordRepository _chatRecordRepository; private readonly ILoginContext _loginContext; public ChatRecordController(ILogger logger, IChatRecordRepository chatRecordRepository,ILoginContext loginContext) { _logger = logger; _chatRecordRepository = chatRecordRepository; _loginContext = loginContext; } /// /// 添加聊天信息 /// /// /// [HttpPost("add")] public async Task Insert(ChatRecordInRequest request) { request.SendUserId = _loginContext.AccountId; return await _chatRecordRepository.InsertAsync(request); } /// /// 聊天消息查询 /// /// /// [HttpPost("history")] public async Task> SearchChatRecordHistoryAsync(ChatRecordSearchHistoryRequest request) { request.UserId = _loginContext.AccountId; return await _chatRecordRepository.SearchChatRecordHistoryAsync(request); } } }