AddressBookGroupUserController.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System.Threading.Tasks;
  2. using GxPress.Auth;
  3. using GxPress.Repository.Interface;
  4. using GxPress.Repository.Interface.Friends;
  5. using GxPress.Request.AddressBookGroupUser;
  6. using GxPress.Result.AddressBookGroupUser;
  7. using GxPress.Service.Interface.AddressBookGroup;
  8. using Microsoft.AspNetCore.Authorization;
  9. using Microsoft.AspNetCore.Mvc;
  10. using Microsoft.Extensions.Logging;
  11. namespace GxPress.Api.AppControllers
  12. {
  13. /// <summary>
  14. /// 通讯录用户信息
  15. /// </summary>
  16. [Route("api/app/address-book-group-user")]
  17. [ApiController]
  18. [Authorize]
  19. public class AddressBookGroupUserController : ControllerBase
  20. {
  21. private readonly ILogger<AppVersionController> _logger;
  22. private readonly IAddressBookGroupUserRepository _addressBookGroupUserRepository;
  23. private readonly ILoginContext _loginContext;
  24. private readonly IFriendsRepository friendsRepository;
  25. private readonly IAddressBookGroupService addressBookGroupService;
  26. public AddressBookGroupUserController(ILogger<AppVersionController> logger,
  27. IAddressBookGroupUserRepository addressBookGroupUserRepository,
  28. ILoginContext loginContext, IFriendsRepository friendsRepository,IAddressBookGroupService addressBookGroupService)
  29. {
  30. _logger = logger;
  31. _addressBookGroupUserRepository = addressBookGroupUserRepository;
  32. _loginContext = loginContext;
  33. this.friendsRepository = friendsRepository;
  34. this.addressBookGroupService=addressBookGroupService;
  35. }
  36. /// <summary>
  37. /// 删除
  38. /// </summary>
  39. /// <param name="id"></param>
  40. /// <returns></returns>
  41. [HttpDelete("{id}")]
  42. public async Task<bool> Delete(int id)
  43. {
  44. return await _addressBookGroupUserRepository.DeleteAsync(id);
  45. }
  46. /// <summary>
  47. /// 删除自建分组用户
  48. /// </summary>
  49. /// <returns></returns>
  50. [HttpPost("delete")]
  51. public async Task<bool> Deletes(AddressBookGroupUserDeleteRequest request)
  52. {
  53. request.UserId = _loginContext.AccountId;
  54. return await addressBookGroupService.DeleteAddressBookGroupUserAsync(request);
  55. }
  56. /// <summary>
  57. /// 获取
  58. /// </summary>
  59. /// <param name="request"></param>
  60. /// <returns></returns>
  61. [HttpPost("list")]
  62. public async Task<AddressBookGroupUserListResult> GetAddressBookGroupUserList(
  63. AddressBookGroupUserSearchRequest request)
  64. {
  65. var userId = _loginContext.AccountId;
  66. return await _addressBookGroupUserRepository.GetAddressBookGroupUserListAsync(request, userId);
  67. }
  68. /// <summary>
  69. /// 添加
  70. /// </summary>
  71. /// <param name="request"></param>
  72. /// <returns></returns>
  73. [HttpPost("add")]
  74. public async Task<bool> Insert(AddressBookGroupUserInRequest request)
  75. {
  76. if (await _addressBookGroupUserRepository.InsertAsync(request))
  77. {
  78. return await friendsRepository.UpdateAddressBookGroupId(request.UserId, _loginContext.AccountId, request.AddressBookGroupId);
  79. }
  80. return false;
  81. }
  82. /// <summary>
  83. /// 移动分组成员
  84. /// </summary>
  85. /// /// <param name="request"></param>
  86. /// <returns></returns>
  87. [HttpPost("move")]
  88. public async Task<bool> AddressBookGroupUserMove(AddressBookGroupUserMoveRequest request)
  89. {
  90. return await _addressBookGroupUserRepository.AddressBookGroupUserMoveAsync(request);
  91. }
  92. }
  93. }