OftenContactController.cs 4.0 KB

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