using System.Collections.Generic; using System.Threading.Tasks; using GxPress.Auth; using GxPress.Repository.Interface; using GxPress.Request.AddressBookGroup; using GxPress.Result.AddressBook; using GxPress.Result.AddressBookGroup; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; namespace GxPress.Api.AppControllers { /// /// 用户通讯录组 /// [Route("api/app/address-book-group")] [ApiController] [Authorize] public class AddressBookGroupController : ControllerBase { private readonly ILogger _logger; private readonly IAddressBookGroupRepository _addressBookGroupRepository; private readonly ILoginContext _loginContext; public AddressBookGroupController(ILogger logger, IAddressBookGroupRepository addressBookGroupRepository, ILoginContext loginContext) { _logger = logger; _addressBookGroupRepository = addressBookGroupRepository; _loginContext = loginContext; } /// /// 删除 /// /// /// [HttpDelete("{id}")] public async Task Delete(int id) { return await _addressBookGroupRepository.DeleteAsync(id); } /// /// 修改 /// /// /// [HttpPost("update")] public async Task Update(AddressBookGroupUpRequest request) { return await _addressBookGroupRepository.UpdateAsync(request); } /// /// 获取 /// /// [HttpPost("list")] public async Task> GetAddressBookGroupList(AddressBookGroupSearchRequest request) { request.UserId = _loginContext.AccountId; return await _addressBookGroupRepository.GetAddressBookGroupListAsync(request); } /// /// 添加 /// /// /// [HttpPost("add")] public async Task Insert(AddressBookGroupInRequest request) { request.UserId = _loginContext.AccountId; return await _addressBookGroupRepository.InsertAsync(request); } /// /// 获取用户通讯录组 /// /// [HttpPost("list-group")] public async Task GetAddressBookList() { AddressBookListRequest request = new AddressBookListRequest { UserId = _loginContext.AccountId }; return await _addressBookGroupRepository.GetAddressBookListAsync(request); } /// /// 添加联系人 /// /// /// [HttpPost("add-address-book-user")] public async Task InsertAddressBookUser(AddressBookInUserRequest request) { return await _addressBookGroupRepository.InsertAddressBookUserAsync(request); } /// /// 自建分组移动排序 /// /// /// [HttpPost("sort")] public async Task Sort(AddressBookGroupSortRequest request) { request.UserId = _loginContext.AccountId; return await _addressBookGroupRepository.SortAsync(request); } } }