李昊 4 years ago
parent
commit
be89a5a3b1

+ 14 - 3
gx_api/GxPress/Api/GxPress.Api/AppControllers/UserController.cs

@@ -1,9 +1,11 @@
 using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
+using System.Linq;
 using System.Security.Claims;
 using System.Text;
 using System.Threading.Tasks;
+using AutoMapper;
 using Datory.Utils;
 using GxPress.Api.Tools;
 using GxPress.Auth;
@@ -50,9 +52,10 @@ namespace GxPress.Api.AppControllers
         private readonly IUserLoginRepository userLoginRepository;
         private readonly IUserMiddleService userMiddleService;
         private readonly IFriendsRepository friendsRepository;
+        private readonly IMapper _mapper;
         public UserController(IUserRepository userRepository, IOptions<JwtOptions> jwtOptions,
             ILogger<UserController> logger, IDepartmentRepository departmentRepository, ILoginContext loginContext,
-            IUserService userService, IFileLibraryRepository fileLibraryRepository, IDistributedCache cache, IUserLoginRepository userLoginRepository, IUserMiddleService userMiddleService, IFriendsRepository friendsRepository)
+            IUserService userService, IFileLibraryRepository fileLibraryRepository, IDistributedCache cache, IUserLoginRepository userLoginRepository, IUserMiddleService userMiddleService, IFriendsRepository friendsRepository, IMapper _mapper)
         {
             _userRepository = userRepository;
             _departmentRepository = departmentRepository;
@@ -65,6 +68,7 @@ namespace GxPress.Api.AppControllers
             this.userLoginRepository = userLoginRepository;
             this.userMiddleService = userMiddleService;
             this.friendsRepository = friendsRepository;
+            this._mapper = _mapper;
         }
         /// <summary>
         /// 登录
@@ -418,9 +422,16 @@ namespace GxPress.Api.AppControllers
         /// <param name="userMiddles">来源类型 1:通知收件人 2:通知抄送人 3:站内信收集人 4:站内信抄送人 5:话题  6:笔记共享文件夹 7:收藏共享文件夹 </param>
         /// <returns></returns>
         [HttpPost("user-middle")]
-        public async Task<List<Entity.User>> FindUsersAsync(UserMiddles userMiddles)
+        public async Task<List<UserInfoResult>> FindUsersAsync(UserMiddles userMiddles)
         {
-            return await userMiddleService.FindUsersAsync(userMiddles.Item, _loginContext.AccountId);
+            var model = await userMiddleService.FindUsersAsync(userMiddles.Item, _loginContext.AccountId);
+            var result = model.Select(n => _mapper.Map<UserInfoResult>(n)).ToList();
+            foreach (var item in result)
+            {
+                item.TypeId = 0;
+                item.TypeValue = 0;
+            }
+            return result;
         }
         /// <summary>
         /// 查询不是好友的用户

+ 27 - 1
gx_api/GxPress/Api/GxPress.Api/WebControllers/UserController.cs

@@ -33,6 +33,11 @@ using Microsoft.Extensions.Caching.Distributed;
 using Microsoft.Extensions.Logging;
 using Microsoft.Extensions.Options;
 using GxPress.Service.Interface.Department;
+using GxPress.Request.UserMiddle;
+using GxPress.Service.Interface.UserMiddle;
+using System.Linq;
+using AutoMapper;
+
 namespace GxPress.Api.WebControllers
 {
     /// <summary>
@@ -57,9 +62,11 @@ namespace GxPress.Api.WebControllers
         private readonly IAddressBookGroupUserRepository _addressBookGroupUserRepository;
         private readonly IFeedbackRepository _feedbackRepository;
         private readonly IFriendsRepository friendsRepository;
+        private readonly IUserMiddleService userMiddleService;
+        private readonly IMapper _mapper;
         public UserController(IUserRepository userRepository, IOptions<JwtOptions> jwtOptions,
             ILogger<UserController> logger, IDepartmentRepository departmentRepository, ILoginContext loginContext,
-            IUserService userService, IFileLibraryRepository fileLibraryRepository, IDistributedCache cache, IUserLoginRepository userLoginRepository, IAddressBookGroupRepository addressBookGroupRepository, IAddressBookGroupUserRepository _addressBookGroupUserRepository, IFeedbackRepository _feedbackRepository, IFriendsRepository friendsRepository, IDepartmentService departmentService)
+            IUserService userService, IFileLibraryRepository fileLibraryRepository, IDistributedCache cache, IUserLoginRepository userLoginRepository, IAddressBookGroupRepository addressBookGroupRepository, IAddressBookGroupUserRepository _addressBookGroupUserRepository, IFeedbackRepository _feedbackRepository, IFriendsRepository friendsRepository, IDepartmentService departmentService, IUserMiddleService userMiddleService,IMapper _mapper)
         {
             _userRepository = userRepository;
             _departmentRepository = departmentRepository;
@@ -75,6 +82,8 @@ namespace GxPress.Api.WebControllers
             this._feedbackRepository = _feedbackRepository;
             this.friendsRepository = friendsRepository;
             this.departmentService = departmentService;
+            this.userMiddleService = userMiddleService;
+            this._mapper=_mapper;
         }
         /// <summary>
         /// 登录
@@ -513,5 +522,22 @@ namespace GxPress.Api.WebControllers
             request.UserId = _loginContext.AccountId;
             return await _userService.GetGroupOrGroupChatUserInfosResult(request);
         }
+        /// <summary>
+        /// 获取用户列表
+        /// </summary>
+        /// <param name="userMiddles">来源类型 1:通知收件人 2:通知抄送人 3:站内信收集人 4:站内信抄送人 5:话题  6:笔记共享文件夹 7:收藏共享文件夹 </param>
+        /// <returns></returns>
+        [HttpPost("user-middle")]
+        public async Task<List<UserInfoResult>> FindUsersAsync(UserMiddles userMiddles)
+        {
+            var model = await userMiddleService.FindUsersAsync(userMiddles.Item, _loginContext.AccountId);
+            var result = model.Select(n => _mapper.Map<UserInfoResult>(n)).ToList();
+            foreach (var item in result)
+            {
+                item.TypeId = 0;
+                item.TypeValue = 0;
+            }
+            return result;
+        }
     }
 }

+ 0 - 1
gx_api/GxPress/Model/GxPress.Mappings/UserMapping.cs

@@ -1,6 +1,5 @@
 using AutoMapper;
 using GxPress.Entity;
-using GxPress.Result.App.Note;
 using GxPress.Result.Notice;
 using GxPress.Result.User;
 

+ 7 - 2
gx_api/GxPress/Repository/GxPress.Repository.Implement/Note/NoteRepository.cs

@@ -88,8 +88,13 @@ namespace GxPress.Repository.Implement.Note
                     .QueryAsync<NotePageListRequest>(GetCollectionSql(request));
             foreach (var item in result)
             {
-                item.FolderName=item.FolderParentName;
-                item.FolderId=item.ParentId;
+                if (string.IsNullOrEmpty(item.FolderName))
+                {
+                    item.FolderName = item.FolderParentName;
+                    item.FolderId = item.ParentId;
+                }
+                else
+                    item.FolderId = item.Id;
                 item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl);
             }
             pagedList.Items = result;

+ 1 - 0
gx_api/GxPress/Service/GxPress.Service.Implement/UserMiddle/UserMiddleService.cs

@@ -195,6 +195,7 @@ namespace GxPress.Service.Implement.UserMiddle
             {
                 item.AvatarUrl = Common.Tools.StringUtils.AddDomainMin(item.AvatarUrl);
             }
+        
             return users;
         }
         /// <summary>