123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- using System.Threading.Tasks;
- using GxPress.Auth;
- using GxPress.Repository.Interface;
- using GxPress.Repository.Interface.Friends;
- using GxPress.Request.AddressBookGroupUser;
- using GxPress.Result.AddressBookGroupUser;
- using GxPress.Service.Interface.AddressBookGroup;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- namespace GxPress.Api.AppControllers
- {
- /// <summary>
- /// 通讯录用户信息
- /// </summary>
- [Route("api/app/address-book-group-user")]
- [ApiController]
- [Authorize]
- public class AddressBookGroupUserController : ControllerBase
- {
- private readonly ILogger<AppVersionController> _logger;
- private readonly IAddressBookGroupUserRepository _addressBookGroupUserRepository;
- private readonly ILoginContext _loginContext;
- private readonly IFriendsRepository friendsRepository;
- private readonly IAddressBookGroupService addressBookGroupService;
- public AddressBookGroupUserController(ILogger<AppVersionController> logger,
- IAddressBookGroupUserRepository addressBookGroupUserRepository,
- ILoginContext loginContext, IFriendsRepository friendsRepository,IAddressBookGroupService addressBookGroupService)
- {
- _logger = logger;
- _addressBookGroupUserRepository = addressBookGroupUserRepository;
- _loginContext = loginContext;
- this.friendsRepository = friendsRepository;
- this.addressBookGroupService=addressBookGroupService;
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("{id}")]
- public async Task<bool> Delete(int id)
- {
- return await _addressBookGroupUserRepository.DeleteAsync(id);
- }
- /// <summary>
- /// 删除自建分组用户
- /// </summary>
- /// <returns></returns>
- [HttpPost("delete")]
- public async Task<bool> Deletes(AddressBookGroupUserDeleteRequest request)
- {
- request.UserId = _loginContext.AccountId;
- return await addressBookGroupService.DeleteAddressBookGroupUserAsync(request);
- }
- /// <summary>
- /// 获取
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("list")]
- public async Task<AddressBookGroupUserListResult> GetAddressBookGroupUserList(
- AddressBookGroupUserSearchRequest request)
- {
- var userId = _loginContext.AccountId;
- return await _addressBookGroupUserRepository.GetAddressBookGroupUserListAsync(request, userId);
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("add")]
- public async Task<bool> Insert(AddressBookGroupUserInRequest request)
- {
- if (await _addressBookGroupUserRepository.InsertAsync(request))
- {
- return await friendsRepository.UpdateAddressBookGroupId(request.UserId, _loginContext.AccountId, request.AddressBookGroupId);
- }
- return false;
- }
- /// <summary>
- /// 移动分组成员
- /// </summary>
- /// /// <param name="request"></param>
- /// <returns></returns>
- [HttpPost("move")]
- public async Task<bool> AddressBookGroupUserMove(AddressBookGroupUserMoveRequest request)
- {
- return await _addressBookGroupUserRepository.AddressBookGroupUserMoveAsync(request);
- }
- }
- }
|