OftenContactController.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. /// 添加
  44. /// </summary>
  45. /// <param name="request"></param>
  46. /// <returns></returns>
  47. [HttpPost("add")]
  48. public async Task<OftenContactDto> Insert(OftenContactInRequest request)
  49. {
  50. var result = new OftenContactDto();
  51. result = await _oftenContactService.InsertAsync(request, _loginContext.AccountId);
  52. return result;
  53. }
  54. /// <summary>
  55. /// /// 移除文件夹关系
  56. /// </summary>
  57. /// <param name="request"></param>
  58. /// <returns></returns>
  59. [HttpPost("remove")]
  60. public async Task<bool> RemoveOftenContact(OftenContactDeRequest request)
  61. {
  62. return await _repository.RemoveOftenContactAsync(request);
  63. }
  64. /// <summary>
  65. /// 设置置顶
  66. /// </summary>
  67. /// <param name="request"></param>
  68. /// <returns></returns>
  69. [HttpPost("is-top")]
  70. public async Task<bool> SetOftenContactIsTop(OftenContactDeRequest request)
  71. {
  72. return await _repository.SetOftenContactIsTopAsync(request);
  73. }
  74. /// <summary>
  75. /// 移动到文件夹
  76. /// </summary>
  77. /// <param name="request"></param>
  78. /// <returns></returns>
  79. [HttpPost("move")]
  80. public async Task<bool> MoveOftenContactToIndividualGroup(OftenContactUpRequest request)
  81. {
  82. return await _repository.MoveOftenContactToIndividualGroupAsync(request);
  83. }
  84. /// <summary>
  85. /// 删除聊天界面
  86. /// </summary>
  87. /// <param name="oftenContactIds"></param>
  88. /// <returns></returns>
  89. [HttpPost("delete")]
  90. public async Task<bool> DeleteAsync(OftenContactsDeRequest oftenContactIds)
  91. {
  92. return await _repository.DeleteAsync(oftenContactIds.OftenContactIds);
  93. }
  94. }
  95. }