|
@@ -0,0 +1,109 @@
|
|
|
|
+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
|
|
|
|
+{
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 用户通讯录组
|
|
|
|
+ /// </summary>
|
|
|
|
+ [Route("api/web/address-book-group")]
|
|
|
|
+ [ApiController]
|
|
|
|
+ [Authorize]
|
|
|
|
+ public class WebAddressBookGroupController : ControllerBase
|
|
|
|
+ {
|
|
|
|
+ private readonly ILogger<AddressBookGroupController> _logger;
|
|
|
|
+ private readonly IAddressBookGroupRepository _addressBookGroupRepository;
|
|
|
|
+ private readonly ILoginContext _loginContext;
|
|
|
|
+
|
|
|
|
+ public WebAddressBookGroupController(ILogger<AddressBookGroupController> logger, IAddressBookGroupRepository addressBookGroupRepository, ILoginContext loginContext)
|
|
|
|
+ {
|
|
|
|
+ _logger = logger;
|
|
|
|
+ _addressBookGroupRepository = addressBookGroupRepository;
|
|
|
|
+ _loginContext = loginContext;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 删除
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="id"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpDelete("{id}")]
|
|
|
|
+ public async Task<bool> Delete(int id)
|
|
|
|
+ {
|
|
|
|
+ return await _addressBookGroupRepository.DeleteAsync(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 修改
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="request"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("update")]
|
|
|
|
+ public async Task<bool> Update(AddressBookGroupUpRequest request)
|
|
|
|
+ {
|
|
|
|
+ return await _addressBookGroupRepository.UpdateAsync(request);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 获取
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("list")]
|
|
|
|
+ public async Task<IEnumerable<AddressBookGroupResult>> GetAddressBookGroupList(AddressBookGroupSearchRequest request)
|
|
|
|
+ {
|
|
|
|
+ request.UserId = _loginContext.AccountId;
|
|
|
|
+ return await _addressBookGroupRepository.GetAddressBookGroupListAsync(request);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 添加
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="request"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("add")]
|
|
|
|
+ public async Task<Entity.AddressBookGroup> Insert(AddressBookGroupInRequest request)
|
|
|
|
+ {
|
|
|
|
+ request.UserId = _loginContext.AccountId;
|
|
|
|
+ return await _addressBookGroupRepository.InsertAsync(request);
|
|
|
|
+ }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 获取用户通讯录组
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("list-group")]
|
|
|
|
+ public async Task<AddressBookListResult> GetAddressBookList()
|
|
|
|
+ {
|
|
|
|
+ AddressBookListRequest request = new AddressBookListRequest { UserId = _loginContext.AccountId };
|
|
|
|
+ return await _addressBookGroupRepository.GetAddressBookListAsync(request);
|
|
|
|
+ }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 添加联系人
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="request"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("add-address-book-user")]
|
|
|
|
+ public async Task<bool> InsertAddressBookUser(AddressBookInUserRequest request)
|
|
|
|
+ {
|
|
|
|
+ return await _addressBookGroupRepository.InsertAddressBookUserAsync(request);
|
|
|
|
+ }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 自建分组移动排序
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="request"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("sort")]
|
|
|
|
+ public async Task<bool> Sort(AddressBookGroupSortRequest request)
|
|
|
|
+ {
|
|
|
|
+ request.UserId = _loginContext.AccountId;
|
|
|
|
+ return await _addressBookGroupRepository.SortAsync(request);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|