ChatRecordController.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Threading.Tasks;
  2. using GxPress.Auth;
  3. using GxPress.Common.Page;
  4. using GxPress.Repository.Interface;
  5. using GxPress.Request.App.ChatRecord;
  6. using GxPress.Result.App.ChatRecord;
  7. using Microsoft.AspNetCore.Authorization;
  8. using Microsoft.AspNetCore.Mvc;
  9. using Microsoft.Extensions.Logging;
  10. namespace GxPress.Api.AppControllers
  11. {
  12. /// <summary>
  13. /// 聊天信息
  14. /// </summary>
  15. [Route("api/app/chat-record")]
  16. [ApiController]
  17. [Authorize]
  18. public class ChatRecordController : ControllerBase
  19. {
  20. private readonly ILogger<AppVersionController> _logger;
  21. private readonly IChatRecordRepository _chatRecordRepository;
  22. private readonly ILoginContext _loginContext;
  23. public ChatRecordController(ILogger<AppVersionController> logger, IChatRecordRepository chatRecordRepository,ILoginContext loginContext)
  24. {
  25. _logger = logger;
  26. _chatRecordRepository = chatRecordRepository;
  27. _loginContext = loginContext;
  28. }
  29. /// <summary>
  30. /// 添加聊天信息
  31. /// </summary>
  32. /// <param name="request"></param>
  33. /// <returns></returns>
  34. [HttpPost("add")]
  35. public async Task<bool> Insert(ChatRecordInRequest request)
  36. {
  37. request.SendUserId = _loginContext.AccountId;
  38. return await _chatRecordRepository.InsertAsync(request);
  39. }
  40. /// <summary>
  41. /// 聊天消息查询
  42. /// </summary>
  43. /// <param name="request"></param>
  44. /// <returns></returns>
  45. [HttpPost("history")]
  46. public async Task<PagedList<ChatRecordSearchHistoryResult>> SearchChatRecordHistoryAsync(ChatRecordSearchHistoryRequest request)
  47. {
  48. request.UserId = _loginContext.AccountId;
  49. return await _chatRecordRepository.SearchChatRecordHistoryAsync(request);
  50. }
  51. }
  52. }