OftenContactController.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System.Threading.Tasks;
  2. using GxPress.Auth;
  3. using GxPress.Repository.Interface;
  4. using GxPress.Request.App.OftenContact;
  5. using GxPress.Result.App.OftenContact;
  6. using Microsoft.AspNetCore.Authorization;
  7. using Microsoft.AspNetCore.Mvc;
  8. using Microsoft.Extensions.Logging;
  9. using GxPress.Service.Interface.OftenContact;
  10. namespace GxPress.Api.AppControllers
  11. {
  12. /// <summary>
  13. /// 好友
  14. /// </summary>
  15. [Route("api/app/often-contact")]
  16. [ApiController]
  17. [Authorize]
  18. public partial class OftenContactController : ControllerBase
  19. {
  20. private readonly ILogger<OftenContactController> _logger;
  21. private readonly IOftenContactRepository _repository;
  22. private readonly ILoginContext _loginContext;
  23. private readonly IOftenContactService _oftenContactService;
  24. public OftenContactController(ILogger<OftenContactController> logger, IOftenContactRepository repository, ILoginContext loginContext, IOftenContactService oftenContactService)
  25. {
  26. _logger = logger;
  27. _repository = repository;
  28. _loginContext = loginContext;
  29. _oftenContactService = oftenContactService;
  30. }
  31. /// <summary>
  32. /// 根据文件ID获取用户和下面的数据
  33. /// </summary>
  34. /// <param name="request"></param>
  35. /// <returns></returns>
  36. [HttpPost("list")]
  37. public async Task<System.Collections.Generic.IEnumerable<OftenContactInfo>> GetOftenContactsAsync(OftenContactSearchRequest request)
  38. {
  39. request.UserId = _loginContext.AccountId;
  40. return await _oftenContactService.GetOftenContacts(request);
  41. }
  42. /// <summary>
  43. /// 根据文件ID获取用户和下面的数据
  44. /// </summary>
  45. /// <param name="request"></param>
  46. /// <returns></returns>
  47. [HttpPost("all-list")]
  48. public async Task<System.Collections.Generic.IEnumerable<OftenContactInfo>> GetOftenContactAllAsync(OftenContactSearchRequest request)
  49. {
  50. request.UserId = _loginContext.AccountId;
  51. return await _oftenContactService.GetOftenContactsAll(request);
  52. }
  53. /// <summary>
  54. /// 添加
  55. /// </summary>
  56. /// <param name="request"></param>
  57. /// <returns></returns>
  58. [HttpPost("add")]
  59. public async Task<OftenContactDto> Insert(OftenContactInRequest request)
  60. {
  61. var result = new OftenContactDto();
  62. result = await _oftenContactService.InsertAsync(request, _loginContext.AccountId);
  63. return result;
  64. }
  65. /// <summary>
  66. /// /// 移除文件夹关系
  67. /// </summary>
  68. /// <param name="request"></param>
  69. /// <returns></returns>
  70. [HttpPost("remove")]
  71. public async Task<bool> RemoveOftenContact(OftenContactDeRequest request)
  72. {
  73. return await _repository.RemoveOftenContactAsync(request);
  74. }
  75. /// <summary>
  76. /// 设置置顶
  77. /// </summary>
  78. /// <param name="request"></param>
  79. /// <returns></returns>
  80. [HttpPost("is-top")]
  81. public async Task<bool> SetOftenContactIsTop(OftenContactDeRequest request)
  82. {
  83. return await _repository.SetOftenContactIsTopAsync(request);
  84. }
  85. /// <summary>
  86. /// 移动到文件夹
  87. /// </summary>
  88. /// <param name="request"></param>
  89. /// <returns></returns>
  90. [HttpPost("move")]
  91. public async Task<bool> MoveOftenContactToIndividualGroup(OftenContactUpRequest request)
  92. {
  93. return await _repository.MoveOftenContactToIndividualGroupAsync(request);
  94. }
  95. /// <summary>
  96. /// 删除聊天界面
  97. /// </summary>
  98. /// <param name="oftenContactIds"></param>
  99. /// <returns></returns>
  100. [HttpPost("delete")]
  101. public async Task<bool> DeleteAsync(OftenContactsDeRequest oftenContactIds)
  102. {
  103. return await _repository.DeleteAsync(oftenContactIds.OftenContactIds);
  104. }
  105. }
  106. }