李昊 před 4 roky
rodič
revize
2eb7ce9183

+ 109 - 0
gx_api/GxPress/Api/GxPress.Api/WebControllers/AddressBookGroupController.cs

@@ -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);
+        }
+    }
+}

+ 82 - 0
gx_api/GxPress/Api/GxPress.Api/WebControllers/AddressBookGroupUserController.cs

@@ -0,0 +1,82 @@
+using System.Threading.Tasks;
+using GxPress.Auth;
+using GxPress.Repository.Interface;
+using GxPress.Request.AddressBookGroupUser;
+using GxPress.Result.AddressBookGroupUser;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace GxPress.Api.AppControllers
+{
+    /// <summary>
+    /// 通讯录用户信息
+    /// </summary>
+    [Route("api/web/address-book-group-user")]
+    [ApiController]
+    [Authorize]
+    public class WebAddressBookGroupUserController : ControllerBase
+    {
+        private readonly ILogger<AppVersionController> _logger;
+        private readonly IAddressBookGroupUserRepository _addressBookGroupUserRepository;
+        private readonly ILoginContext _loginContext;
+        public WebAddressBookGroupUserController(ILogger<AppVersionController> logger, IAddressBookGroupUserRepository addressBookGroupUserRepository, ILoginContext loginContext)
+        {
+            _logger = logger;
+            _addressBookGroupUserRepository = addressBookGroupUserRepository;
+            _loginContext = loginContext;
+        }
+
+        /// <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)
+        {
+            return await _addressBookGroupUserRepository.DeletesAsync(request.Ids);
+        }
+        /// <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)
+        {
+            return await _addressBookGroupUserRepository.InsertAsync(request);
+        }
+        /// <summary>
+        /// 移动分组成员
+        /// </summary>
+        /// /// <param name="request"></param>
+        /// <returns></returns>
+        [HttpPost("move")]
+        public async Task<bool> AddressBookGroupUserMove(AddressBookGroupUserMoveRequest request)
+        {
+            return await _addressBookGroupUserRepository.AddressBookGroupUserMoveAsync(request);
+        }
+    }
+}